Skip to content

Commit

Permalink
more cli args cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Sep 10, 2019
1 parent af53133 commit 82a9052
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/vs/platform/environment/common/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,13 @@ export interface ParsedArgs {
'driver-verbose'?: boolean;
remote?: string;
'disable-user-env-probe'?: boolean;
'enable-remote-auto-shutdown'?: boolean;
'disable-inspect'?: boolean;
'force'?: boolean;
'gitCredential'?: string;

// node flags
'js-flags'?: string;
'disable-gpu'?: boolean;
'nolazy'?: boolean;

// Web flags
'web-user-data-dir'?: string;
}

export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService');
Expand Down
13 changes: 11 additions & 2 deletions src/vs/platform/environment/node/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ type OptionTypeName<T> =
T extends undefined ? 'undefined' :
'unknown';

export const OPTIONS: OptionDescriptions<ParsedArgs> = {
export const OPTIONS: OptionDescriptions<Required<ParsedArgs>> = {
'diff': { type: 'boolean', cat: 'o', alias: 'd', args: ['file', 'file'], description: localize('diff', "Compare two files with each other.") },
'add': { type: 'boolean', cat: 'o', alias: 'a', args: 'folder', description: localize('add', "Add folder(s) to the last active window.") },
'goto': { type: 'boolean', cat: 'o', alias: 'g', args: 'file:line[:character]', description: localize('goto', "Open a file at the path on the specified line and character position.") },
'new-window': { type: 'boolean', cat: 'o', alias: 'n', description: localize('newWindow', "Force to open a new window.") },
'reuse-window': { type: 'boolean', cat: 'o', alias: 'r', description: localize('reuseWindow', "Force to open a file or folder in an already opened window.") },
'wait': { type: 'boolean', cat: 'o', alias: 'w', description: localize('wait', "Wait for the files to be closed before returning.") },
'waitMarkerFilePath': { type: 'string' },
'locale': { type: 'string', cat: 'o', args: 'locale', description: localize('locale', "The locale to use (e.g. en-US or zh-TW).") },
'user-data-dir': { type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") },
'version': { type: 'boolean', cat: 'o', alias: 'v', description: localize('version', "Print version.") },
Expand All @@ -56,6 +57,7 @@ export const OPTIONS: OptionDescriptions<ParsedArgs> = {
'file-uri': { type: 'string[]', cat: 'o', args: 'uri', description: localize('fileUri', "Opens a window with given file uri(s)") },

'extensions-dir': { type: 'string', deprecates: 'extensionHomePath', cat: 'e', args: 'dir', description: localize('extensionHomePath', "Set the root path for extensions.") },
'builtin-extensions-dir': { type: 'string' },
'list-extensions': { type: 'boolean', cat: 'e', description: localize('listExtensions', "List the installed extensions.") },
'show-versions': { type: 'boolean', cat: 'e', description: localize('showVersions', "Show versions of installed extensions, when using --list-extension.") },
'category': { type: 'string', cat: 'e', description: localize('category', "Filters installed extensions by provided category, when using --list-extension.") },
Expand All @@ -67,8 +69,8 @@ export const OPTIONS: OptionDescriptions<ParsedArgs> = {
'log': { type: 'string', cat: 't', args: 'level', description: localize('log', "Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.") },
'status': { type: 'boolean', alias: 's', cat: 't', description: localize('status', "Print process usage and diagnostics information.") },
'prof-startup': { type: 'boolean', cat: 't', description: localize('prof-startup', "Run CPU profiler during startup") },
'prof-startup-prefix': { type: 'string' },
'prof-append-timers': { type: 'string' },
'prof-startup-prefix': { type: 'string' },
'disable-extensions': { type: 'boolean', deprecates: 'disableExtensions', cat: 't', description: localize('disableExtensions', "Disable all installed extensions.") },
'disable-extension': { type: 'string[]', cat: 't', args: 'extension-id', description: localize('disableExtension', "Disable an extension.") },

Expand Down Expand Up @@ -96,19 +98,22 @@ export const OPTIONS: OptionDescriptions<ParsedArgs> = {
'disable-telemetry': { type: 'boolean' },
'disable-updates': { type: 'boolean' },
'disable-crash-reporter': { type: 'boolean' },
'disable-user-env-probe': { type: 'boolean' },
'skip-add-to-recently-opened': { type: 'boolean' },
'unity-launch': { type: 'boolean' },
'open-url': { type: 'boolean' },
'file-write': { type: 'boolean' },
'file-chmod': { type: 'boolean' },
'driver-verbose': { type: 'boolean' },
'force': { type: 'boolean' },
'trace': { type: 'boolean' },
'trace-category-filter': { type: 'string' },
'trace-options': { type: 'string' },
'disable-inspect': { type: 'boolean' },

'js-flags': { type: 'string' }, // chrome js flags
'nolazy': { type: 'boolean' }, // node inspect
'_urls': { type: 'string[]' },

_: { type: 'string[]' } // main arguments
};
Expand All @@ -128,6 +133,10 @@ export function parseArgs<T>(args: string[], options: OptionDescriptions<T>, err
const string: string[] = [];
const boolean: string[] = [];
for (let optionId in options) {
if (optionId[0] === '_') {
continue;
}

const o = options[optionId];
if (o.alias) {
alias[optionId] = o.alias;
Expand Down
4 changes: 1 addition & 3 deletions src/vs/platform/environment/node/environmentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ export class EnvironmentService implements IEnvironmentService {
return parseUserDataDir(this._args, process);
}

@memoize
get webUserDataHome(): URI { return URI.file(parsePathArg(this._args['web-user-data-dir'], process) || this.userDataPath); }

get appNameLong(): string { return product.nameLong; }

Expand Down Expand Up @@ -285,7 +283,7 @@ function parseDebugPort(debugArg: string | undefined, debugBrkArg: string | unde
return { port, break: brk, debugId };
}

function parsePathArg(arg: string | undefined, process: NodeJS.Process): string | undefined {
export function parsePathArg(arg: string | undefined, process: NodeJS.Process): string | undefined {
if (!arg) {
return undefined;
}
Expand Down

0 comments on commit 82a9052

Please sign in to comment.