diff --git a/README.md b/README.md index f9b6f33..ef06590 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. diff --git a/src/Command.ts b/src/Command.ts index e7eeeee..eb37c20 100644 --- a/src/Command.ts +++ b/src/Command.ts @@ -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 } diff --git a/src/index.ts b/src/index.ts index 7fa5f25..dbabe19 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 }