mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-22 14:48:28 +00:00
This commit is contained in:
parent
1f6e74b1e3
commit
8600c78d1a
@ -113,6 +113,7 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
|
||||
// Whether the window should always stay on top of other windows. Default is false.
|
||||
alwaysOnTop: options.alwaysOnTop,
|
||||
titleBarStyle: options.titleBarStyle,
|
||||
show: options.tray !== 'start-in-tray',
|
||||
},
|
||||
DEFAULT_WINDOW_OPTIONS,
|
||||
),
|
||||
|
@ -519,11 +519,13 @@ Prevents application from being run multiple times. If such an attempt occurs th
|
||||
#### [tray]
|
||||
|
||||
```
|
||||
--tray
|
||||
--tray [start-in-tray]
|
||||
```
|
||||
|
||||
Application will stay as an icon in the system tray. Prevents application from being closed from clicking the window close button.
|
||||
|
||||
When the optional argument `start-in-tray` is provided, i.e. the application is started using `--tray start-in-tray`, the main window will not be shown on first start.
|
||||
|
||||
#### [basic-auth-username]
|
||||
|
||||
```
|
||||
|
35
src/cli.js
35
src/cli.js
@ -13,6 +13,17 @@ function collect(val, memo) {
|
||||
return memo;
|
||||
}
|
||||
|
||||
function parseMaybeBoolString(val) {
|
||||
switch (val) {
|
||||
case 'true':
|
||||
return true;
|
||||
case 'false':
|
||||
return false;
|
||||
default:
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
function parseJson(val) {
|
||||
if (!val) return {};
|
||||
return JSON.parse(val);
|
||||
@ -36,6 +47,22 @@ function checkInternet() {
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
const sanitizedArgs = [];
|
||||
process.argv.forEach((arg) => {
|
||||
if (sanitizedArgs.length > 0) {
|
||||
const previousArg = sanitizedArgs[sanitizedArgs.length - 1];
|
||||
|
||||
// Work around commander.js not supporting default argument for options
|
||||
if (
|
||||
previousArg === '--tray' &&
|
||||
!['true', 'false', 'start-in-tray'].includes(arg)
|
||||
) {
|
||||
sanitizedArgs.push('true');
|
||||
}
|
||||
}
|
||||
sanitizedArgs.push(arg);
|
||||
});
|
||||
|
||||
program
|
||||
.version(packageJson.version, '-v, --version')
|
||||
.arguments('<targetUrl> [dest]')
|
||||
@ -191,7 +218,11 @@ if (require.main === module) {
|
||||
'a JSON string of key/value pairs to be set as file download options. See https://github.com/sindresorhus/electron-dl for available options.',
|
||||
parseJson,
|
||||
)
|
||||
.option('--tray', 'allow app to stay in system tray')
|
||||
.option(
|
||||
'--tray [start-in-tray]',
|
||||
"Allow app to stay in system tray. If 'start-in-tray' is given as argument, don't show main window on first start",
|
||||
parseMaybeBoolString,
|
||||
)
|
||||
.option('--basic-auth-username <value>', 'basic http(s) auth username')
|
||||
.option('--basic-auth-password <value>', 'basic http(s) auth password')
|
||||
.option('--always-on-top', 'enable always on top window')
|
||||
@ -203,7 +234,7 @@ if (require.main === module) {
|
||||
'--global-shortcuts <value>',
|
||||
'JSON file with global shortcut configuration. See https://github.com/jiahaog/nativefier/blob/master/docs/api.md#global-shortcuts',
|
||||
)
|
||||
.parse(process.argv);
|
||||
.parse(sanitizedArgs);
|
||||
|
||||
if (!process.argv.slice(2).length) {
|
||||
program.help();
|
||||
|
Loading…
x
Reference in New Issue
Block a user