Archived
1
0

Add support for multiline descriptions

This commit is contained in:
Anmol Sethi 2020-09-08 20:30:31 -04:00
parent c7c62daa67
commit 916e24e109
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB

View File

@ -131,8 +131,8 @@ const options: Options<Required<Args>> = {
force: { type: "boolean", description: "Avoid prompts when installing VS Code extensions." }, force: { type: "boolean", description: "Avoid prompts when installing VS Code extensions." },
"install-extension": { "install-extension": {
type: "string[]", type: "string[]",
description: description: "Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" +
"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'.", "To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.",
}, },
"enable-proposed-api": { "enable-proposed-api": {
type: "string[]", type: "string[]",
@ -158,8 +158,14 @@ const options: Options<Required<Args>> = {
log: { type: LogLevel }, log: { type: LogLevel },
verbose: { type: "boolean", short: "vvv", description: "Enable verbose logging." }, 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" + "expose": {
"like https://myname.coder-cloud.com at which you can easily access your code-server instance. Authorization is done via GitHub." }, 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[] => { export const optionDescriptions = (): string[] => {
@ -172,10 +178,16 @@ export const optionDescriptions = (): string[] => {
{ short: 0, long: 0 }, { short: 0, long: 0 },
) )
return entries.map( return entries.map(
([k, v]) => ([k, v]) => {
`${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k}${" ".repeat( let help = `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k} `
widths.long - k.length, return help + v.description?.trim().split(/\n/).map((line, i) => {
)} ${v.description}`, line = line.trim()
if (i == 0) {
return " ".repeat(widths.long - k.length) + line
}
return " ".repeat(widths.long + widths.short + 6) + line
}).join("\n")
},
) )
} }