diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2023-04-19 10:25:50 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2023-04-19 13:37:31 +0200 |
| commit | a40097cb5bcbc8b85d8bb23f6b2f32b6fab7a5ff (patch) | |
| tree | 1030be86900f168969a5b524b6d6c842964d0519 /gui/src/main | |
| parent | ec33228db6c8c014a67fccd2cd9f2fae9fc414f6 (diff) | |
| download | mullvadvpn-a40097cb5bcbc8b85d8bb23f6b2f32b6fab7a5ff.tar.xz mullvadvpn-a40097cb5bcbc8b85d8bb23f6b2f32b6fab7a5ff.zip | |
Add command line help option
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/command-line-options.ts | 32 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 25 |
2 files changed, 43 insertions, 14 deletions
diff --git a/gui/src/main/command-line-options.ts b/gui/src/main/command-line-options.ts index a7300d1f83..01cf2ae331 100644 --- a/gui/src/main/command-line-options.ts +++ b/gui/src/main/command-line-options.ts @@ -1,22 +1,22 @@ class CommandLineOption { - private options: string[]; + private flags: string[]; - public constructor(private description: string, ...options: string[]) { - this.options = options; + public constructor(private description: string, ...flags: string[]) { + this.flags = flags; } public get match(): boolean { - return this.options.some((option) => process.argv.includes(option)); + return this.flags.some((flag) => process.argv.includes(flag)); } public format(): string { - return formatOption(this.description, ...this.options); + return formatOption(this.description, ...this.flags); } } class DevelopmentCommandLineOption extends CommandLineOption { - public constructor(...options: string[]) { - super('', ...options); + public constructor(...flags: string[]) { + super('', ...flags); } public get match(): boolean { @@ -25,6 +25,7 @@ class DevelopmentCommandLineOption extends CommandLineOption { } export const CommandLineOptions = { + help: new CommandLineOption('Print this help text', '--help', '-h'), showChanges: new CommandLineOption('Show changes dialog', '--show-changes'), disableResetNavigation: new DevelopmentCommandLineOption('--disable-reset-navigation'), disableDevtoolsOpen: new DevelopmentCommandLineOption('--disable-devtools-open'), @@ -39,9 +40,18 @@ export function printCommandLineOptions() { }); } -function formatOption(description: string, ...options: string[]) { - const joinedOptions = options.join(', '); +export function printElectronOptions() { + console.log(formatOption('Run without renderer process sandboxed', '--no-sandbox')); + console.log(formatOption('Run without hardware acceleration for graphics', '--disable-gpu')); +} + +// This functions format options into one line, e.g. +// --help Print this help text +// The line starts with 4 spaces and the flags and description are separated with spaces to align +// the descriptions +function formatOption(description: string, ...flags: string[]) { + const joinedFlags = flags.join(', '); const padding = ' '; - const paddedOptions = (joinedOptions + padding).slice(0, -joinedOptions.length); - return ' ' + paddedOptions + description; + const paddedFlags = (joinedFlags + padding).slice(0, -joinedFlags.length); + return ' ' + paddedFlags + description; } diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index f14ed2ee3f..613d1a92e9 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -27,7 +27,11 @@ import { import Account, { AccountDelegate, LocaleProvider } from './account'; import { getOpenAtLogin } from './autostart'; import { readChangelog } from './changelog'; -import { CommandLineOptions, printCommandLineOptions } from './command-line-options'; +import { + CommandLineOptions, + printCommandLineOptions, + printElectronOptions, +} from './command-line-options'; import { ConnectionObserver, DaemonRpc, SubscriptionListener } from './daemon-rpc'; import Expectation from './expectation'; import { IpcMainEventChannel } from './ipc-event-channel'; @@ -1040,5 +1044,20 @@ class ApplicationMain /* eslint-enable @typescript-eslint/member-ordering */ } -const applicationMain = new ApplicationMain(); -applicationMain.run(); +if (CommandLineOptions.help.match) { + console.log('Mullvad VPN'); + console.log('Graphical interface for managing the Mullvad VPN daemon'); + + console.log(''); + console.log('OPTIONS:'); + printCommandLineOptions(); + + console.log(''); + console.log('USEFUL ELECTRON/CHROMIUM OPTIONS:'); + printElectronOptions(); + + process.exit(0); +} else { + const applicationMain = new ApplicationMain(); + applicationMain.run(); +} |
