Skip to content

feat: upgrade to latest commander and clean up interface - #1327

Closed
grabbou wants to merge 9 commits into
next-newfrom
cli/options-validate
Closed

grabbou wants to merge 9 commits into
next-newfrom
cli/options-validate

Conversation

@grabbou

@grabbou grabbou commented Nov 25, 2020 •

Copy link
Copy Markdown
Member

Upgrades Commander to the latest version and removes some of the hacks that were put up in place.

Changes:

  • You can now write --paths <list...> and have your option automatically accept array values. No need for custom parsing and splitting by a comma
  • Hacky printHelpInformation was removed

Breaking changes:

  • It now matters how you define your options, e.g. --name <string> and --name [string] previously had no effect. In this version, name <string> means that --name must always include a value and passing --name will throw an error. This prevents issues when users invoke CLI with --port and not provide value. For --name [string], [] indicate that the value is optional and can be either boolean --name or string --name Mike. This should prevent issues like fix: options for init command have required arguments #1324
  • Options should now be passed with a space, not with a comma, e.g. --paths a b c instead of --paths a,b,c. This only affects commands built-in to the CLI. Other community plugins have an opportunity to take advantage of the new interface, but it will not be turned on automatically, unless option declaration is updated.

Comment thread packages/cli/src/commands/link/link.ts Resolved
Comment thread packages/cli/src/index.ts Resolved
Comment thread packages/cli/src/index.ts
/**
* Extend built-in help information by displaying examples, if defined
*/
cmd.on('--help', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly, doesn't work on('command:config'). Need to try again.

Comment thread packages/cli/src/index.ts Resolved
Comment thread packages/cli/src/index.ts Resolved
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
@grabbou
grabbou changed the base branch from master to next November 26, 2020 10:06
@grabbou
grabbou changed the base branch from next to next-new November 26, 2020 10:09
@grabbou

grabbou commented Nov 26, 2020

Copy link
Copy Markdown
Member Author

Related issue to handle: #1261 (comment)

@grabbou

grabbou commented Dec 7, 2020

Copy link
Copy Markdown
Member Author

Closing as part of it already landed. Will submit a follow-up soon with a different take.

@grabbou grabbou closed this Dec 7, 2020
@grabbou
grabbou deleted the cli/options-validate branch February 25, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants