From 916e24e1098d21893e4df6b0ec5a1d3723d71987 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 8 Sep 2020 20:30:31 -0400 Subject: [PATCH] Add support for multiline descriptions --- src/node/cli.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/node/cli.ts b/src/node/cli.ts index 8830531f..318b8593 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -131,8 +131,8 @@ const options: Options> = { force: { type: "boolean", description: "Avoid prompts when installing VS Code extensions." }, "install-extension": { type: "string[]", - description: - "Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`. To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.", + description: "Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" + + "To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.", }, "enable-proposed-api": { type: "string[]", @@ -158,8 +158,14 @@ const options: Options> = { log: { type: LogLevel }, verbose: { type: "boolean", short: "vvv", description: "Enable verbose logging." }, - "expose": { type: OptionalString, description: "Expose via Coder Cloud with the passed name. You'll get a URL" + - "like https://myname.coder-cloud.com at which you can easily access your code-server instance. Authorization is done via GitHub." }, + "expose": { + type: OptionalString, + description: ` + Securely expose code-server via Coder Cloud with the passed name. You'll get a URL like + https://myname.coder-cloud.com at which you can easily access your code-server instance. + Authorization is done via GitHub. Only the first code-server spawned with the current + configuration will be accessible.` + }, } export const optionDescriptions = (): string[] => { @@ -172,10 +178,16 @@ export const optionDescriptions = (): string[] => { { short: 0, long: 0 }, ) return entries.map( - ([k, v]) => - `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k}${" ".repeat( - widths.long - k.length, - )} ${v.description}`, + ([k, v]) => { + let help = `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k} ` + return help + v.description?.trim().split(/\n/).map((line, i) => { + line = line.trim() + if (i == 0) { + return " ".repeat(widths.long - k.length) + line + } + return " ".repeat(widths.long + widths.short + 6) + line + }).join("\n") + }, ) }