From 54e3a5194faa4734bf16f0c21e2a11eb6c0c6bd3 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Mon, 9 Sep 2019 15:31:00 +0200 Subject: [PATCH] fix help --- src/vs/platform/environment/node/argv.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index e4b2dfa51ca..e639efb6f59 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -30,17 +30,16 @@ export interface Option { } export type OptionDescriptions = { - [P in keyof T]: Option>; + [P in keyof T]: Option>; }; -type TypeName = +type OptionTypeName = T extends boolean ? 'boolean' : T extends string ? 'string' : T extends string[] ? 'string[]' : T extends undefined ? 'undefined' : 'unknown'; -//_urls export const OPTIONS: OptionDescriptions = { '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.") }, @@ -264,11 +263,15 @@ export function buildHelpMessage(productName: string, executableName: string, ve } help.push(''); } - const optionsByCategory: { [P in keyof typeof helpCategories]: OptionDescriptions } = { e: {}, o: {}, t: {} }; + const optionsByCategory: { [P in keyof typeof helpCategories]?: OptionDescriptions } = {}; for (const optionId in options) { const o = options[optionId]; if (o.description && o.cat) { - optionsByCategory[o.cat][optionId] = o; + let optionsByCat = optionsByCategory[o.cat]; + if (!optionsByCat) { + optionsByCategory[o.cat] = optionsByCat = {}; + } + optionsByCat[optionId] = o; } } @@ -276,7 +279,7 @@ export function buildHelpMessage(productName: string, executableName: string, ve const key = helpCategoryKey; let categoryOptions = optionsByCategory[key]; - if (categoryOptions.length) { + if (categoryOptions) { help.push(helpCategories[key]); help.push(...formatOptions(categoryOptions, columns)); help.push(''); -- GitLab