Skip to content

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

Merged
bcoe merged 3 commits into
masterfrom
implicit-help-command
Aug 7, 2016
Merged

feat: .help() API can now enable implicit help command#574
bcoe merged 3 commits into
masterfrom
implicit-help-command

Conversation

@nexdrew

@nexdrew nexdrew commented Aug 3, 2016

Copy link
Copy Markdown
Member

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.

2 participants