Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: .help() API can now enable implicit help command #574

Merged
merged 3 commits into from Aug 7, 2016

Conversation

nexdrew
Copy link
Member

@nexdrew nexdrew commented Aug 3, 2016

In addition to a flagged option (e.g. --help), .help() now also supports an implicit command (e.g. help), which is enabled by default.

This means any yargs CLI can now enjoy commands such as:

$ cli help
$ cli help command
$ cli command help

No flag needed. 馃槑

I opted to build the implicit command into the existing .help() API (instead of creating a new method) in order to:

  1. reuse the same tokens for the flag and the command
  2. enable it by default for most uses of .help()

It can be explicitly disabled by passing false as one of the 3 arguments.

Note that any help option aliases will also be used as an alias for the command, as long as:

  1. the alias has a length greater than 1, or
  2. all aliases have a length of 1

This should be considered a 5.x breaking change in case existing CLIs use their own help command.

@nexdrew nexdrew added the 5.x label Aug 3, 2016
@bcoe bcoe merged commit 7645019 into master Aug 7, 2016
@nexdrew nexdrew deleted the implicit-help-command branch August 9, 2016 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants