Skip to content

Commit

Permalink
feat: allow to use custom flags to output version
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 26, 2018
1 parent 4d15c3b commit e51fe6e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- [cli.command(name, description)](#clicommandname-description)
- [cli.option(name, description, config?)](#clioptionname-description-config)
- [cli.parse(argv?)](#cliparseargv)
- [cli.version(version)](#cliversionversion)
- [cli.version(version, customFlags?)](#cliversionversion-customflags)
- [cli.help(callback?)](#clihelpcallback)
- [cli.outputHelp(subCommand?)](#clioutputhelpsubcommand)
- [Command Instance](#command-instance)
Expand Down Expand Up @@ -268,9 +268,9 @@ interface ParsedArgv {

When this method is called, `cli.rawArgs` `cli.args` `cli.options` `cli.matchedCommand` will also be available.

#### cli.version(version)
#### cli.version(version, customFlags?)

- Type: `(version: string) => CLI`
- Type: `(version: string, customFlags = '-v, --version') => CLI`

Output version number when `-v, --version` flag appears.

Expand Down
4 changes: 2 additions & 2 deletions src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export default class Command {
return this
}

version(version: string) {
version(version: string, customFlags = '-v, --version') {
this.versionNumber = version
this.option('-v, --version', 'Display version number')
this.option(customFlags, 'Display version number')
return this
}

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class CAC extends EventEmitter {
return this
}

version(version: string) {
this.globalCommand.version(version)
version(version: string, customFlags = '-v, --version') {
this.globalCommand.version(version, customFlags)
return this
}

Expand Down

0 comments on commit e51fe6e

Please sign in to comment.