Comparing version 6.3.6 to 6.3.7
@@ -395,7 +395,7 @@ 'use strict'; | ||
outputHelp() { | ||
const { bin, commands } = this.cli; | ||
const { name, commands } = this.cli; | ||
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand; | ||
const sections = [ | ||
{ | ||
body: `${bin}${versionNumber ? ` v${versionNumber}` : ''}` | ||
body: `${name}${versionNumber ? ` v${versionNumber}` : ''}` | ||
} | ||
@@ -405,3 +405,3 @@ ]; | ||
title: 'Usage', | ||
body: ` $ ${bin} ${this.usageText || this.rawName}` | ||
body: ` $ ${name} ${this.usageText || this.rawName}` | ||
}); | ||
@@ -422,3 +422,3 @@ const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0; | ||
body: commands | ||
.map(command => ` $ ${bin}${command.name === '' ? '' : ` ${command.name}`} --help`) | ||
.map(command => ` $ ${name}${command.name === '' ? '' : ` ${command.name}`} --help`) | ||
.join('\n') | ||
@@ -449,3 +449,3 @@ }); | ||
if (typeof example === 'function') { | ||
return example(bin); | ||
return example(name); | ||
} | ||
@@ -470,6 +470,6 @@ return example; | ||
outputVersion() { | ||
const { bin } = this.cli; | ||
const { name } = this.cli; | ||
const { versionNumber } = this.cli.globalCommand; | ||
if (versionNumber) { | ||
console.log(`${bin}/${versionNumber} ${process.platform}-${process.arch} node-${process.version}`); | ||
console.log(`${name}/${versionNumber} ${process.platform}-${process.arch} node-${process.version}`); | ||
} | ||
@@ -544,4 +544,8 @@ process.exit(0); | ||
class CAC extends events.EventEmitter { | ||
constructor() { | ||
/** | ||
* @param name The program name to display in help and version message | ||
*/ | ||
constructor(name = '') { | ||
super(); | ||
this.name = name; | ||
this.commands = []; | ||
@@ -643,3 +647,5 @@ this.globalCommand = new Command_1$$1.GlobalCommand(this); | ||
this.rawArgs = argv; | ||
this.bin = argv[1] ? path_1.default.basename(argv[1]) : 'cli'; | ||
if (!this.name) { | ||
this.name = argv[1] ? path_1.default.basename(argv[1]) : 'cli'; | ||
} | ||
let shouldParse = true; | ||
@@ -646,0 +652,0 @@ // Search sub-commands |
{ | ||
"name": "cac", | ||
"version": "6.3.6", | ||
"version": "6.3.7", | ||
"description": "Simple yet powerful framework for building command-line apps.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -33,2 +33,3 @@ <img width="945" alt="2017-07-26 9 27 05" src="https://user-images.githubusercontent.com/8784712/28623641-373450f4-7249-11e7-854d-1b076dab274d.png"> | ||
- [CLI Instance](#cli-instance) | ||
- [cac(name?)](#cacname) | ||
- [cli.command(name, description, config?)](#clicommandname-description-config) | ||
@@ -257,2 +258,6 @@ - [cli.option(name, description, config?)](#clioptionname-description-config) | ||
#### cac(name?) | ||
Create a CLI instance, optionally specify the program name which will be used to display in help and version message. When not set we use the basename of `argv[1]`. | ||
#### cli.command(name, description, config?) | ||
@@ -375,3 +380,3 @@ | ||
```ts | ||
type CommandExample = ((bin: string) => string) | string | ||
type CommandExample = ((name: string) => string) | string | ||
``` | ||
@@ -378,0 +383,0 @@ |
@@ -17,3 +17,4 @@ /// <reference types="node" /> | ||
declare class CAC extends EventEmitter { | ||
bin: string; | ||
/** The program name to display in help and version message */ | ||
name: string; | ||
commands: Command[]; | ||
@@ -38,4 +39,7 @@ globalCommand: GlobalCommand; | ||
rawOptions: MriResult['rawOptions']; | ||
constructor(); | ||
/** | ||
* @param name The program name to display in help and version message | ||
*/ | ||
constructor(name?: string); | ||
/** | ||
* Add a global usage text. | ||
@@ -42,0 +46,0 @@ * |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45688
944
435