提交 2eb18932 编写于 作者: D Daniel Imms

Add --help and --version command line args

Fixes #378
上级 0bf4c2ca
......@@ -85,7 +85,8 @@
"typescript": "^1.7.3",
"uglify-js": "2.4.8",
"underscore": "^1.8.2",
"vinyl": "^0.4.5"
"vinyl": "^0.4.5",
"yargs": "^3.32.0"
},
"repository": {
"type": "git",
......
......@@ -10,6 +10,7 @@ global.vscodeStart = Date.now();
var app = require('electron').app;
var path = require('path');
var process = require('process');
var fs = require('fs');
// Change cwd if given via env variable
......@@ -19,6 +20,31 @@ try {
// noop
}
function parseArgs() {
var executable = 'code' + (os.platform() == 'win32' ? '.exe' : '');
var options = require('yargs')(process.argv.slice(1));
options.usage(
'Visual Studio Code v' + app.getVersion() + '\n' +
'\n' +
'Usage: ' + executable + ' [arguments] [path]');
options.alias('h', 'help').boolean('h').describe('h', 'Print usage.');
options.string('locale').describe('locale', 'Use a specific locale.');
options.boolean('n').describe('n', 'Force a new instance of code.');
options.alias('v', 'version').boolean('v').describe('v', 'Print version.');
var args = options.argv;
if (args.help) {
process.stdout.write(options.help());
process.exit(0);
}
if (args.version) {
process.stdout.write(app.getVersion());
process.exit(0);
}
}
parseArgs();
// Set path according to being built or not
if (!!process.env.VSCODE_DEV) {
var appData = app.getPath('appData');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册