Add -h/--help usage message
This commit is contained in:
parent
f4a27f699a
commit
da07e72f20
1 changed files with 14 additions and 2 deletions
|
@ -11,11 +11,14 @@ app.on('window-all-closed', function() {
|
||||||
|
|
||||||
// Parse command line options.
|
// Parse command line options.
|
||||||
var argv = process.argv.slice(1);
|
var argv = process.argv.slice(1);
|
||||||
var option = { file: null, version: null, webdriver: null };
|
var option = { file: null, help: null, version: null, webdriver: null };
|
||||||
for (var i in argv) {
|
for (var i in argv) {
|
||||||
if (argv[i] == '--version' || argv[i] == '-v') {
|
if (argv[i] == '--version' || argv[i] == '-v') {
|
||||||
option.version = true;
|
option.version = true;
|
||||||
break;
|
break;
|
||||||
|
} else if (argv[i] == '--help' || argv[i] == '-h') {
|
||||||
|
option.help = true;
|
||||||
|
break;
|
||||||
} else if (argv[i] == '--test-type=webdriver') {
|
} else if (argv[i] == '--test-type=webdriver') {
|
||||||
option.webdriver = true;
|
option.webdriver = true;
|
||||||
} else if (argv[i][0] == '-') {
|
} else if (argv[i][0] == '-') {
|
||||||
|
@ -58,7 +61,16 @@ if (option.file && !option.webdriver) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (option.version) {
|
} else if (option.version) {
|
||||||
console.log('v' + process.versions['electron']);
|
console.log('v' + process.versions.electron);
|
||||||
|
process.exit(0);
|
||||||
|
} else if (option.help) {
|
||||||
|
var helpMessage = "Electron v" + process.versions.electron + " - Cross Platform Desktop Application Shell\n\n";
|
||||||
|
helpMessage += "Usage: electron [options] [path]\n\n";
|
||||||
|
helpMessage += "Specify a path to the Electron app to open\n\n";
|
||||||
|
helpMessage += "Options:\n";
|
||||||
|
helpMessage += " -h, --help Print this usage message.\n";
|
||||||
|
helpMessage += " -v, --version Print the version.";
|
||||||
|
console.log(helpMessage);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
require('./default_app.js');
|
require('./default_app.js');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue