Replace yargs-parser with commander for CLI option parsing#1192
Draft
Replace yargs-parser with commander for CLI option parsing#1192
Conversation
- Replace yargs-parser with commander package (v10, Node 14+ compatible) - Remove yargs-parser and @types/yargs-parser dependencies - Ban unknown options (commander rejects unrecognized options) - Remove --bool=false and --bool false support in favor of --no-bool - Duplicate non-array options now use last-write-wins instead of throwing - CamelCase input (--gitTags) no longer accepted; use hyphenated (--git-tags) - Update tests to match new behavior - All existing options, aliases, and commands preserved Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/b10c3147-797f-4524-a56d-1f2537833d47
Copilot created this pull request from a session on behalf of
ecraig12345
March 28, 2026 05:57
View session
ecraig12345
reviewed
Mar 28, 2026
ecraig12345
reviewed
Mar 28, 2026
src/options/getCliOptions.ts
Outdated
Comment on lines
+155
to
+163
| // Handle --config as alias for --config-path | ||
| if (commanderOpts.config !== undefined) { | ||
| if (commanderOpts.configPath !== undefined) { | ||
| throw new Error('Cannot specify both --config and --config-path'); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| commanderOpts.configPath = commanderOpts.config; | ||
| } | ||
| delete commanderOpts.config; |
Member
There was a problem hiding this comment.
@copilot Use commander's built-in alias support instead
Member
There was a problem hiding this comment.
@copilot Change it so --config is the primary option, and --config-path is an alias. You can handle it with new Option(...).alias('--config-path')
Contributor
Author
There was a problem hiding this comment.
Switched to --config as the primary option (with -c short form) and --config-path as a hidden alias. Commander v10 doesn't have .alias() on Option, so both are defined as separate options with --config-path hidden via .hideHelp(). The post-processing merges both into the configPath field on cliOptions. Done in 44c6910.
The CLI parser now requires a command name in argv. Updated all test files that passed argv: [] to getParsedOptions to include the appropriate command name (bump, change, check, or publish) based on each test's context. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use .command() for all known commands (change, check, bump, publish, canary, init, sync) - Add config get <name> and config list as proper subcommands with positional arg - Add option descriptions for commander-generated help text - Remove default command (subcommand is now required) - Replace _extraPositionalArgs with configSettingName - Remove showHelp() in favor of commander's built-in help - Remove CliOptions.help and CliOptions.version (commander handles these) - Handle commander help/version errors in cli.ts catch block - Use standard program.version() format - Update all tests for new subcommand structure Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/637df71a-fa66-490b-98ee-ab96f3469c64
…ith --config-path alias Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/13e97a54-84b3-4b4c-adf8-9f0ff9ae878d
… alias upgrade, update docs Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/1f3e4a87-1bdd-40c9-a3e1-53277fb750ba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.command()for all known commands (no default command)CliOptions.helpandCliOptions.version(commander handles these natively)cli.tsdispatch forconfig get/config listand CommanderError handlingconfigGet.tsto useconfigSettingName--configis now the primary option;--config-pathis a hidden aliasOption.alias()--configas the primary optionBefore and after behavior
--helpshowHelp()output--versioncli.ts--version--gitTags)--git-tags) with helpful suggestions--no-X(yargs implicit)--no-Xoptions defined per flag--config-pathprimary,--confighidden--configprimary (-c),--config-pathhidden aliasconfigcommand_extraPositionalArgsconfig get <name>,config list--helpoutput--gitTags→Did you mean --git-tags or --no-git-tags?)📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.