Comparing version 1.0.19 to 1.0.20
@@ -71,2 +71,3 @@ export declare type ArgumentValue = any; | ||
subCommands: CommandDefinition[]; | ||
extra?: any; | ||
}; | ||
@@ -89,2 +90,3 @@ export declare class CliCommand { | ||
private negatableOptsMap; | ||
private extra; | ||
private onProcessQueue; | ||
@@ -112,2 +114,3 @@ private parsed; | ||
withVersion(version: string, handler?: (command: CommandDefinition) => void): CliCommand; | ||
withExtra(extra: any): CliCommand; | ||
dump(dumped?: CliCommand[]): CommandDefinition; | ||
@@ -114,0 +117,0 @@ /** |
@@ -28,2 +28,3 @@ "use strict"; | ||
this.negatableOptsMap = {}; // Maps --no-* flags to negatable options | ||
this.extra = undefined; // Arbitrary data (e.g. documentation) to append to a dumped command | ||
// Maintain option/argument assignment order to call onProcess() hooks in the order they were defined | ||
@@ -155,2 +156,6 @@ this.onProcessQueue = []; | ||
} | ||
withExtra(extra) { | ||
this.extra = extra; | ||
return this; | ||
} | ||
dump(dumped = []) { | ||
@@ -163,2 +168,3 @@ return { | ||
args: Object.values(this.argsMap).map(a => this.dumpArgument(a)), | ||
extra: this.extra, | ||
subCommands: dumped.includes(this) | ||
@@ -165,0 +171,0 @@ ? [] // Prevent endless recursion |
{ | ||
"name": "cilly", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"description": "The last library you'll ever need for building intuitive, robust and flexible CLI tools with Node.js and TypeScript.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -644,2 +644,15 @@ # Cilly | ||
Arbitrary data can be appended to dumped command objects using the `.withExtra()` method, e.g.: | ||
```typescript | ||
new CliCommand('build') | ||
.withExtra({ | ||
documentationSections: [ | ||
{ type: 'title', content: 'Running the build command' }, | ||
{ type: 'body', content: 'When running the build command, ...' }, | ||
... | ||
] | ||
}) | ||
``` | ||
Here's an example of a command dump: | ||
@@ -646,0 +659,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
77096
1180
779