feat(cli): LTRAC-612 show global options in subcommand help#2992
Conversation
🦋 Changeset detectedLatest commit: bd9229e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Bundle Size ReportComparing against baseline from No bundle size changes detected. |
3bb6b3e to
2872d7d
Compare
Apply `.configureHelp({ showGlobalOptions: true })` to every Command and
subcommand so `catalyst <command> --help` surfaces the root-level
`--env-path` option (and other globals) under a "Global Options"
section. Previously these were only visible on `catalyst --help`.
Refs LTRAC-612
Co-Authored-By: Claude <noreply@anthropic.com>
2872d7d to
bd9229e
Compare
Command-specificnode ./dist/cli.js auth --help ✔
◢ @bigcommerce/catalyst v1.0.0-alpha.3 3:12:14 PM
Usage: @bigcommerce/catalyst auth [options] [command]
Manage authentication for the BigCommerce CLI.
Options:
-h, --help display help for command
Global Options:
-V, --version output the version number
--env-path <path> Path to environment file to load (relative to current working directory)
Commands:
whoami [options] Verify stored credentials and display store/project info.
login [options] 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.
logout Remove stored credentials for the current project.
help [command] display help for commandGlobalnode ./dist/cli.js --help ✔
◢ @bigcommerce/catalyst v1.0.0-alpha.3 3:12:06 PM
Usage: @bigcommerce/catalyst [options] [command]
CLI tool for Catalyst development.
Configuration priority: flags > env file (--env-path) > process.env > .bigcommerce/project.json.
Run `catalyst <command> --help` for details on a specific command.
Options:
-V, --version output the version number
--env-path <path> Path to environment file to load (relative to current working directory)
-h, --help display help for command
Commands:
version Display detailed version information.
start Start a local preview of your Catalyst storefront using the OpenNext Cloudflare adapter.
build [options] Build your Catalyst project using the OpenNext/Cloudflare build pipeline. Also runs a Wrangler dry-run to generate deployment artifacts.
deploy [options] Deploy your application to Cloudflare.
logs View logs from your deployed application.
project Manage your BigCommerce infrastructure project.
auth Manage authentication for the BigCommerce CLI.
telemetry [options] [arg] View or change CLI telemetry collection status. Enabling telemetry helps BigCommerce support diagnose and troubleshoot errors you encounter when using the CLI.
help [command] display help for command |
| } | ||
|
|
||
| const whoami = new Command('whoami') | ||
| .configureHelp({ showGlobalOptions: true }) |
There was a problem hiding this comment.
Wonder if we are going to have more shared configurations over cli command objects? In that case we should incapsulate that logic.
There was a problem hiding this comment.
Claude initial did that, but I kinda hated it. I think the CLI rarely changes enough that it's fine not creating an abstraction for it – there might be a future case where we don't want to use --env-path in command so best to keep it flexible.
jorgemoya
left a comment
There was a problem hiding this comment.
Thanks, I ran into this yesterday.
Jira: LTRAC-612
What/Why?
The root-level
--env-pathoption (and-V, --version) are defined on the rootprograminpackages/catalyst/src/cli/program.ts, but Commander does not include parent/global options in subcommand--helpoutput by default. Runningcatalyst deploy --help,catalyst auth login --help, etc. omitted--env-pathentirely, which made the option feel hidden to users reading per-command help.This change applies
.configureHelp({ showGlobalOptions: true })directly at eachCommanddefinition site (root, every top-level command, and every nested subcommand likeauth login,logs tail,project create). Commander's per-command config does not propagate to subcommands automatically, so the setting has to be repeated — an explicit per-command call was chosen over a recursive helper for readability.Output is unchanged on
catalyst --help; every subcommand now includes a newGlobal Options:section listing--env-pathand-V, --version.Testing
No runtime behavior changes — purely help-text formatting.
pnpm typecheck,pnpm lint, andpnpm test(131 tests) pass inpackages/catalyst.node dist/cli.js <cmd> --help:catalyst --help— unchanged, still lists--env-pathunder Options.catalyst deploy --help,build --help,start --help,version --help,telemetry --help,logs --help,logs tail --help,auth --help,auth login --help,project --help,project create --help— all now render aGlobal Options:section containing--env-path <path>and-V, --version.Migration
None. No public API or behavior change.