Ir para o conteúdo principal

Classe: Linha de Comando

Classe: Linha de Comando

Manipulate the command line arguments for your app that Chromium reads

Processo: Principal
Esta classe não é exportada do módulo 'electron'. Ele é somente disponibilizado como um valor de retorno de outros métodos na API Electron.

The following example shows how to check if the --disable-gpu flag is set.

const { app } = require('electron')
app.commandLine.hasSwitch('disable-gpu')

For more information on what kinds of flags and switches you can use, check out the Command Line Switches document.

Métodos de Instância

commandLine.appendSwitch(switch[, value])

  • switch string - A command-line switch, without the leading --
  • value string - (opcional) - Um valor para a opção desejada

Insere uma opção (com um value opcional) à linha de comando do Chromium.

Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.

commandLine.appendArgument(value)

  • value string - The argument to append to the command line

Append an argument to Chromium's command line. The argument will be quoted correctly. Switches will precede arguments regardless of appending order.

If you're appending an argument like --switch=value, consider using appendSwitch('switch', 'value') instead.

Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.

commandLine.hasSwitch(switch)

  • switch string - Uma opção de linha de comando

Returns boolean - Whether the command-line switch is present.

commandLine.getSwitchValue(switch)

  • switch string - Uma opção de linha de comando

Returns string - The command-line switch value.

Note: When the switch is not present or has no value, it returns empty string.

commandLine.removeSwitch(switch)

  • switch string - Uma opção de linha de comando

Removes the specified switch from Chromium's command line.

Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.