Skip to content

Commit 591d7b8

Browse files
chanceaclarkclaude
andcommitted
feat(cli): add Commander.js built-in help text to all commands (#2984)
Add .description(), .addHelpText(), and .summary() to all CLI commands so that `catalyst <command> --help` becomes the canonical reference. Hide internal-only options (--api-host, --login-url) from help output. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 250924f commit 591d7b8

12 files changed

Lines changed: 137 additions & 10 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bigcommerce/catalyst": patch
3+
---
4+
5+
Add built-in help text to all CLI commands so `catalyst <command> --help` is the canonical reference.

packages/catalyst/src/cli/commands/auth.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ async function fetchStoreProfile(storeHash: string, accessToken: string, apiHost
4040

4141
const whoami = new Command('whoami')
4242
.description('Verify stored credentials and display store/project info.')
43+
.addHelpText(
44+
'after',
45+
`
46+
Example:
47+
$ catalyst auth whoami
48+
49+
Logged in to My Store (abc123), connected to project my-project (43eba682-0c48-11f1-9bd5-827a48b0ce1e)`,
50+
)
4351
.addOption(
4452
new Option(
4553
'--store-hash <hash>',
@@ -55,7 +63,8 @@ const whoami = new Command('whoami')
5563
.addOption(
5664
new Option('--api-host <host>', 'BigCommerce API host. The default is api.bigcommerce.com.')
5765
.env('BIGCOMMERCE_API_HOST')
58-
.default('api.bigcommerce.com'),
66+
.default('api.bigcommerce.com')
67+
.hideHelp(),
5968
)
6069
.action(async (options) => {
6170
try {
@@ -110,7 +119,19 @@ const whoami = new Command('whoami')
110119
});
111120

112121
const login = new Command('login')
113-
.description('Authenticate via browser using the OAuth device code flow.')
122+
.description(
123+
'Authenticate via browser using the OAuth device code flow. If already logged in, displays current credentials and suggests running `catalyst auth logout` to re-authenticate.',
124+
)
125+
.addHelpText(
126+
'after',
127+
`
128+
Examples:
129+
# Login via browser (recommended)
130+
$ catalyst auth login
131+
132+
# Login with existing credentials (skips browser flow)
133+
$ catalyst auth login --store-hash <STORE_HASH> --access-token <ACCESS_TOKEN>`,
134+
)
114135
.addOption(
115136
new Option(
116137
'--store-hash <hash>',
@@ -126,7 +147,8 @@ const login = new Command('login')
126147
.addOption(
127148
new Option('--login-url <url>', 'BigCommerce login URL.')
128149
.env('BIGCOMMERCE_LOGIN_URL')
129-
.default(DEFAULT_LOGIN_URL),
150+
.default(DEFAULT_LOGIN_URL)
151+
.hideHelp(),
130152
)
131153
.action(async (options) => {
132154
try {
@@ -183,6 +205,12 @@ const login = new Command('login')
183205

184206
const logout = new Command('logout')
185207
.description('Remove stored credentials for the current project.')
208+
.addHelpText(
209+
'after',
210+
`
211+
Example:
212+
$ catalyst auth logout`,
213+
)
186214
.action(() => {
187215
try {
188216
const config = getProjectConfig();

packages/catalyst/src/cli/commands/build.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ export async function buildCatalystProject(projectUuid: string): Promise<void> {
7676
}
7777

7878
export const build = new Command('build')
79+
.description(
80+
'Build your Catalyst project using the OpenNext/Cloudflare build pipeline. Also runs a Wrangler dry-run to generate deployment artifacts.',
81+
)
82+
.addHelpText(
83+
'after',
84+
`
85+
Examples:
86+
$ catalyst build
87+
88+
# Include project UUID
89+
$ catalyst build --project-uuid <UUID>`,
90+
)
7991
.addOption(
8092
new Option(
8193
'--project-uuid <uuid>',

packages/catalyst/src/cli/commands/deploy.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,12 @@ export const fetchProject = async (
370370

371371
export const deploy = new Command('deploy')
372372
.description('Deploy your application to Cloudflare.')
373+
.addHelpText(
374+
'after',
375+
`
376+
Example:
377+
$ catalyst deploy --secret BIGCOMMERCE_STORE_HASH=<YOUR_STORE_HASH> --secret BIGCOMMERCE_STOREFRONT_TOKEN=<YOUR_STOREFRONT_TOKEN>`,
378+
)
373379
.addOption(
374380
new Option(
375381
'--store-hash <hash>',
@@ -385,7 +391,8 @@ export const deploy = new Command('deploy')
385391
.addOption(
386392
new Option('--api-host <host>', 'BigCommerce API host. The default is api.bigcommerce.com.')
387393
.env('BIGCOMMERCE_API_HOST')
388-
.default('api.bigcommerce.com'),
394+
.default('api.bigcommerce.com')
395+
.hideHelp(),
389396
)
390397
.addOption(
391398
new Option(

packages/catalyst/src/cli/commands/logs.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,18 @@ export const tailLogs = async (
233233

234234
const tail = new Command('tail')
235235
.description('Tail live logs from your deployed application.')
236+
.addHelpText(
237+
'after',
238+
`
239+
Examples:
240+
$ catalyst logs tail
241+
242+
# Tail logs with request format
243+
$ catalyst logs tail --format request
244+
245+
# Tail logs as raw JSON (useful for piping to other tools)
246+
$ catalyst logs tail --format json`,
247+
)
236248
.addOption(storeHashOption().makeOptionMandatory())
237249
.addOption(accessTokenOption().makeOptionMandatory())
238250
.addOption(apiHostOption())
@@ -263,6 +275,12 @@ const tail = new Command('tail')
263275

264276
const query = new Command('query')
265277
.description('Query historical logs from your deployed application.')
278+
.addHelpText(
279+
'after',
280+
`
281+
Example:
282+
$ catalyst logs query`,
283+
)
266284
.addOption(storeHashOption().makeOptionMandatory())
267285
.addOption(accessTokenOption().makeOptionMandatory())
268286
.addOption(apiHostOption())

packages/catalyst/src/cli/commands/project.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import { getTelemetry } from '../lib/telemetry';
88

99
const list = new Command('list')
1010
.description('List BigCommerce infrastructure projects for your store.')
11+
.addHelpText(
12+
'after',
13+
`
14+
Example:
15+
$ catalyst project list`,
16+
)
1117
.addOption(
1218
new Option(
1319
'--store-hash <hash>',
@@ -23,7 +29,8 @@ const list = new Command('list')
2329
.addOption(
2430
new Option('--api-host <host>', 'BigCommerce API host. The default is api.bigcommerce.com.')
2531
.env('BIGCOMMERCE_API_HOST')
26-
.default('api.bigcommerce.com'),
32+
.default('api.bigcommerce.com')
33+
.hideHelp(),
2734
)
2835
.action(async (options) => {
2936
const config = getProjectConfig();
@@ -55,6 +62,12 @@ const create = new Command('create')
5562
.description(
5663
'Create a new BigCommerce infrastructure project and link it to your local Catalyst project.',
5764
)
65+
.addHelpText(
66+
'after',
67+
`
68+
Example:
69+
$ catalyst project create`,
70+
)
5871
.addOption(
5972
new Option(
6073
'--store-hash <hash>',
@@ -70,7 +83,8 @@ const create = new Command('create')
7083
.addOption(
7184
new Option('--api-host <host>', 'BigCommerce API host. The default is api.bigcommerce.com.')
7285
.env('BIGCOMMERCE_API_HOST')
73-
.default('api.bigcommerce.com'),
86+
.default('api.bigcommerce.com')
87+
.hideHelp(),
7488
)
7589
.action(async (options) => {
7690
const config = getProjectConfig();
@@ -99,6 +113,16 @@ export const link = new Command('link')
99113
.description(
100114
'Link your local Catalyst project to a BigCommerce infrastructure project. You can provide a project UUID directly, or fetch and select from available projects using your store credentials.',
101115
)
116+
.addHelpText(
117+
'after',
118+
`
119+
Examples:
120+
# Link interactively (prompts to select or create)
121+
$ catalyst project link
122+
123+
# Link using a project UUID directly
124+
$ catalyst project link --project-uuid <UUID>`,
125+
)
102126
.addOption(
103127
new Option(
104128
'--store-hash <hash>',
@@ -114,7 +138,8 @@ export const link = new Command('link')
114138
.addOption(
115139
new Option('--api-host <host>', 'BigCommerce API host. The default is api.bigcommerce.com.')
116140
.env('BIGCOMMERCE_API_HOST')
117-
.default('api.bigcommerce.com'),
141+
.default('api.bigcommerce.com')
142+
.hideHelp(),
118143
)
119144
.option(
120145
'--project-uuid <uuid>',

packages/catalyst/src/cli/commands/start.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ export const start = new Command('start')
99
.description(
1010
'Start a local preview of your Catalyst storefront using the OpenNext Cloudflare adapter.',
1111
)
12+
.addHelpText(
13+
'after',
14+
`
15+
Example:
16+
$ catalyst start`,
17+
)
1218
.action(async () => {
1319
const envLocal = join(process.cwd(), '.env.local');
1420
const devVars = join(process.cwd(), '.bigcommerce', '.dev.vars');

packages/catalyst/src/cli/commands/telemetry.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ const telemetryService = getTelemetry();
88
let isEnabled = telemetryService.isEnabled();
99

1010
export const telemetry = new Command('telemetry')
11+
.description(
12+
'View or change CLI telemetry collection status. Enabling telemetry helps BigCommerce support diagnose and troubleshoot errors you encounter when using the CLI.',
13+
)
14+
.addHelpText(
15+
'after',
16+
`
17+
Examples:
18+
# Show telemetry status
19+
$ catalyst telemetry
20+
21+
# Enable telemetry collection
22+
$ catalyst telemetry enable
23+
24+
# Disable telemetry collection
25+
$ catalyst telemetry --disable`,
26+
)
1127
.addArgument(new Argument('[arg]').choices(['disable', 'enable', 'status']))
1228
.addOption(new Option('--enable', `Enables CLI telemetry collection.`).conflicts('disable'))
1329
.option('--disable', `Disables CLI telemetry collection.`)

packages/catalyst/src/cli/commands/version.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import { consola } from '../lib/logger';
55

66
export const version = new Command('version')
77
.description('Display detailed version information.')
8+
.addHelpText(
9+
'after',
10+
`
11+
Example:
12+
$ catalyst version`,
13+
)
814
.action(() => {
915
consola.log('Version Information:');
1016
consola.log(`CLI Version: ${PACKAGE_INFO.version}`);

packages/catalyst/src/cli/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('CLI program', () => {
1717
expect(program).toBeInstanceOf(Command);
1818
expect(program.name()).toBe(process.env.npm_package_name);
1919
expect(program.version()).toBe(process.env.npm_package_version);
20-
expect(program.description()).toBe('CLI tool for Catalyst development');
20+
expect(program.description()).toContain('CLI tool for Catalyst development');
2121
});
2222

2323
test('has expected commands', () => {

0 commit comments

Comments
 (0)