From 0c6c5c4d643b21d2edbb257955a481ee087f014c Mon Sep 17 00:00:00 2001 From: Manuel Serret Date: Tue, 22 Oct 2024 17:37:57 +0200 Subject: [PATCH 1/2] chore: color help screen --- packages/cli/common.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/cli/common.ts b/packages/cli/common.ts index 346108c7c..df9be01d8 100644 --- a/packages/cli/common.ts +++ b/packages/cli/common.ts @@ -8,7 +8,31 @@ import { COMMANDS, constructCommand, resolveCommand } from 'package-manager-dete import type { Argument, HelpConfiguration, Option } from 'commander'; import type { AdderWithoutExplicitArgs, Precondition } from '@sveltejs/cli-core'; +// partially sourced from https://github.com/tj/commander.js/blob/970ecae402b253de691e6a9066fea22f38fe7431/lib/help.js#L12 export const helpConfig: HelpConfiguration = { + subcommandTerm: (cmd) => { + const humanReadableArgName = (arg: Argument) => { + const nameOutput = arg.name() + (arg.variadic === true ? '...' : ''); + + return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']'; + }; + + // Legacy. Ignores custom usage string, and nested commands. + const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(' '); + const aliases = cmd.aliases(); + return ( + pc.blue(cmd.name()) + + (aliases[0] ? '|' + aliases[0] : '') + + (cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option + (args ? ' ' + args : '') + ); + }, + argumentTerm: (arg) => { + return pc.blue(arg.name()); + }, + optionTerm: (option) => { + return pc.blue(option.flags); + }, argumentDescription: formatDescription, optionDescription: formatDescription }; From 08cc0e4410e1c3063994678691cbfc5f1c563e37 Mon Sep 17 00:00:00 2001 From: Manuel Serret Date: Tue, 22 Oct 2024 17:55:34 +0200 Subject: [PATCH 2/2] changeset --- .changeset/tough-gorillas-switch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tough-gorillas-switch.md diff --git a/.changeset/tough-gorillas-switch.md b/.changeset/tough-gorillas-switch.md new file mode 100644 index 000000000..ff7317a6b --- /dev/null +++ b/.changeset/tough-gorillas-switch.md @@ -0,0 +1,5 @@ +--- +'sv': patch +--- + +chore: color help screen