Comparing version 6.0.1 to 6.0.2
@@ -32,4 +32,4 @@ "use strict"; | ||
} | ||
example(text) { | ||
this.examples.push(text); | ||
example(example) { | ||
this.examples.push(example); | ||
return this; | ||
@@ -120,3 +120,10 @@ } | ||
title: 'Examples', | ||
body: this.examples.map(v => ` ${config.bin} ${v}`).join('\n') | ||
body: this.examples | ||
.map(example => { | ||
if (typeof example === 'function') { | ||
return example(config.bin); | ||
} | ||
return example; | ||
}) | ||
.join('\n') | ||
}); | ||
@@ -123,0 +130,0 @@ } |
{ | ||
"name": "cac", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"description": "Simple yet powerful framework for building command-line apps.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -23,2 +23,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"> | ||
- [With TypeScript](#with-typescript) | ||
- [Projects Using CAC](#projects-using-cac) | ||
- [References](#references) | ||
@@ -217,2 +218,13 @@ - [CLI Instance](#cli-instance) | ||
## Projects Using CAC | ||
Projects that use **CAC**: | ||
- [SAO](https://github.com/egoist/sao): ⚔️ Futuristic scaffolding tool. | ||
- [DocPad](https://github.com/docpad/docpad): 🏹 Powerful Static Site Generator. | ||
- [Poi](https://github.com/egoist/poi): ⚡️ Delightful web development. | ||
- [bili](https://github.com/egoist/bili): 🥂 Schweizer Armeemesser for bundling JavaScript libraries. | ||
- [lass](https://github.com/lassjs/lass): 💁🏻 Scaffold a modern package boilerplate for Node.js. | ||
- Feel free to add yours here... | ||
## References | ||
@@ -336,6 +348,10 @@ | ||
- Type: `(example: string) => Command` | ||
- Type: `(example: CommandExample) => Command` | ||
Add an example which will be displayed at the end of help message. | ||
```ts | ||
type CommandExample = ((bin: string) => string) | string | ||
``` | ||
### Events | ||
@@ -342,0 +358,0 @@ |
@@ -21,2 +21,3 @@ import Option, { OptionConfig } from './Option'; | ||
declare type HelpCallback = (sections: HelpSection[]) => void; | ||
declare type CommandExample = ((bin: string) => string) | string; | ||
export default class Command { | ||
@@ -32,3 +33,3 @@ rawName: string; | ||
versionNumber?: string; | ||
examples: string[]; | ||
examples: CommandExample[]; | ||
config: CommandConfig; | ||
@@ -40,3 +41,3 @@ helpCallback?: HelpCallback; | ||
version(version: string): this; | ||
example(text: string): this; | ||
example(example: CommandExample): this; | ||
/** | ||
@@ -68,2 +69,2 @@ * Add a option for this command | ||
} | ||
export { HelpCallback }; | ||
export { HelpCallback, CommandExample }; |
@@ -5,3 +5,3 @@ /// <reference types="minimist" /> | ||
import { Opts as MinimostOpts } from 'minimost'; | ||
import Command, { HelpCallback } from './Command'; | ||
import Command, { HelpCallback, CommandExample } from './Command'; | ||
import { OptionConfig } from './Option'; | ||
@@ -43,3 +43,3 @@ interface ParsedArgv { | ||
*/ | ||
example(example: string): this; | ||
example(example: CommandExample): this; | ||
outputHelp(): this; | ||
@@ -46,0 +46,0 @@ outputVersion(): this; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
31826
568
400
0