Skip to content

Commit

Permalink
Merge pull request #80560 from microsoft/aeschli/optiondescriptions
Browse files Browse the repository at this point in the history
optionDescriptions as parameter of parseArgs
  • Loading branch information
aeschli authored Sep 9, 2019
2 parents ec9a617 + 54e3a51 commit e45341c
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 170 deletions.
4 changes: 2 additions & 2 deletions src/vs/code/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, R
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { parseArgs } from 'vs/platform/environment/node/argv';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import product from 'vs/platform/product/node/product';
import { IWindowSettings, MenuBarVisibility, IWindowConfiguration, ReadyState, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -574,7 +574,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
windowConfiguration.partsSplashPath = path.join(this.environmentService.userDataPath, 'rapid_render.json');

// Config (combination of process.argv and window configuration)
const environment = parseArgs(process.argv);
const environment = parseArgs(process.argv, OPTIONS);
const config = objects.assign(environment, windowConfiguration);
for (const key in config) {
const configValue = (config as any)[key];
Expand Down
4 changes: 2 additions & 2 deletions src/vs/code/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { spawn, ChildProcess, SpawnOptions } from 'child_process';
import { assign } from 'vs/base/common/objects';
import { buildHelpMessage, buildVersionMessage, addArg, createWaitMarkerFile } from 'vs/platform/environment/node/argv';
import { buildHelpMessage, buildVersionMessage, addArg, createWaitMarkerFile, OPTIONS } from 'vs/platform/environment/node/argv';
import { parseCLIProcessArgv } from 'vs/platform/environment/node/argvHelper';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import product from 'vs/platform/product/node/product';
Expand Down Expand Up @@ -47,7 +47,7 @@ export async function main(argv: string[]): Promise<any> {
// Help
if (args.help) {
const executable = `${product.applicationName}${os.platform() === 'win32' ? '.exe' : ''}`;
console.log(buildHelpMessage(product.nameLong, executable, pkg.version));
console.log(buildHelpMessage(product.nameLong, executable, pkg.version, OPTIONS));
}

// Version Info
Expand Down
33 changes: 16 additions & 17 deletions src/vs/code/test/node/argv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,28 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { formatOptions, Option, addArg } from 'vs/platform/environment/node/argv';
import { ParsedArgs } from 'vs/platform/environment/common/environment';

suite('formatOptions', () => {

function o(id: keyof ParsedArgs, description: string): Option {
function o(description: string): Option<any> {
return {
id, description, type: 'string'
description, type: 'string'
};
}

test('Text should display small columns correctly', () => {
assert.deepEqual(
formatOptions([
o('add', 'bar')
], 80),
formatOptions({
'add': o('bar')
}, 80),
[' --add bar']
);
assert.deepEqual(
formatOptions([
o('add', 'bar'),
o('wait', 'ba'),
o('trace', 'b')
], 80),
formatOptions({
'add': o('bar'),
'wait': o('ba'),
'trace': o('b')
}, 80),
[
' --add bar',
' --wait ba',
Expand All @@ -36,9 +35,9 @@ suite('formatOptions', () => {

test('Text should wrap', () => {
assert.deepEqual(
formatOptions([
o('add', (<any>'bar ').repeat(9))
], 40),
formatOptions({
'add': o((<any>'bar ').repeat(9))
}, 40),
[
' --add bar bar bar bar bar bar bar bar',
' bar'
Expand All @@ -47,9 +46,9 @@ suite('formatOptions', () => {

test('Text should revert to the condensed view when the terminal is too narrow', () => {
assert.deepEqual(
formatOptions([
o('add', (<any>'bar ').repeat(9))
], 30),
formatOptions({
'add': o((<any>'bar ').repeat(9))
}, 30),
[
' --add',
' bar bar bar bar bar bar bar bar bar '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as path from 'vs/base/common/path';
import * as pfs from 'vs/base/node/pfs';
import { URI as Uri, URI } from 'vs/base/common/uri';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { parseArgs } from 'vs/platform/environment/node/argv';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainService';
import { IBackupWorkspacesFormat, ISerializedWorkspace, IWorkspaceBackupInfo } from 'vs/platform/backup/common/backup';
import { HotExitConfiguration } from 'vs/platform/files/common/files';
Expand All @@ -32,7 +32,7 @@ suite('BackupMainService', () => {
const backupHome = path.join(parentDir, 'Backups');
const backupWorkspacesPath = path.join(backupHome, 'workspaces.json');

const environmentService = new EnvironmentService(parseArgs(process.argv), process.execPath);
const environmentService = new EnvironmentService(parseArgs(process.argv, OPTIONS), process.execPath);

class TestBackupMainService extends BackupMainService {

Expand Down
8 changes: 4 additions & 4 deletions src/vs/platform/environment/common/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface ParsedArgs {
'reuse-window'?: boolean;
locale?: string;
'user-data-dir'?: string;
'prof-startup'?: string;
'prof-startup'?: boolean;
'prof-startup-prefix'?: string;
'prof-append-timers'?: string;
verbose?: boolean;
Expand Down Expand Up @@ -61,8 +61,8 @@ export interface ParsedArgs {
'disable-telemetry'?: boolean;
'export-default-configuration'?: string;
'install-source'?: string;
'disable-updates'?: string;
'disable-crash-reporter'?: string;
'disable-updates'?: boolean;
'disable-crash-reporter'?: boolean;
'skip-add-to-recently-opened'?: boolean;
'max-memory'?: string;
'file-write'?: boolean;
Expand All @@ -76,7 +76,7 @@ export interface ParsedArgs {
'force'?: boolean;
'gitCredential'?: string;
// node flags
'js-flags'?: boolean;
'js-flags'?: string;
'disable-gpu'?: boolean;
'nolazy'?: boolean;

Expand Down
Loading

0 comments on commit e45341c

Please sign in to comment.