Comparing version 1.0.2 to 1.0.3
@@ -41,2 +41,3 @@ export declare type ArgumentValue = any; | ||
consumeUnknownOpts?: boolean; | ||
exitOnHelp?: boolean; | ||
}; | ||
@@ -71,2 +72,3 @@ export declare type OptionDefinition = { | ||
private inheritOpts?; | ||
private exitOnHelp?; | ||
private consumeUnknownOpts?; | ||
@@ -141,2 +143,4 @@ private args; | ||
private isEmpty; | ||
private isHelpOption; | ||
private handleHelpOption; | ||
} |
@@ -17,3 +17,7 @@ "use strict"; | ||
class CliCommand { | ||
constructor(name, opts = { inheritOpts: false, consumeUnknownOpts: false }) { | ||
constructor(name, opts = { | ||
inheritOpts: false, | ||
consumeUnknownOpts: false, | ||
exitOnHelp: true | ||
}) { | ||
this.args = []; // Needs to be an array because we have to pick arguments in order | ||
@@ -31,2 +35,3 @@ this.opts = {}; | ||
this.inheritOpts = opts.inheritOpts; | ||
this.exitOnHelp = opts.exitOnHelp; | ||
this.consumeUnknownOpts = opts.consumeUnknownOpts; | ||
@@ -36,9 +41,3 @@ this.helpHandler = presentation_1.showHelp; | ||
name: ['-h', '--help'], | ||
description: 'Display help for command', | ||
hook: (value) => { | ||
if (value) { | ||
this.helpHandler(this.dump()); | ||
process.exit(0); | ||
} | ||
} | ||
description: 'Display help for command' | ||
}); | ||
@@ -131,2 +130,5 @@ } | ||
if (token_parser_1.TokenParser.isOptionName(next)) { | ||
if (this.isHelpOption(next)) { | ||
this.handleHelpOption(); | ||
} | ||
const parsed = this.consumeOption(q); | ||
@@ -436,4 +438,13 @@ if (!parsed) | ||
} | ||
isHelpOption(opt) { | ||
return ['-h', '--help'].includes(opt); | ||
} | ||
handleHelpOption() { | ||
this.helpHandler(this.dump()); | ||
if (this.exitOnHelp) { | ||
process.exit(0); | ||
} | ||
} | ||
} | ||
exports.CliCommand = CliCommand; | ||
//# sourceMappingURL=cli-command.js.map |
{ | ||
"name": "cilly", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "The last library you'll ever need for building intuitive, robust and flexible CLI tools with Node.js and TypeScript.", | ||
@@ -14,3 +14,6 @@ "main": "dist/index.js", | ||
"include": "src", | ||
"exclude": "src/presentation.ts" | ||
"exclude": [ | ||
"src/presentation.ts", | ||
"*/**/*.test.ts" | ||
] | ||
}, | ||
@@ -17,0 +20,0 @@ "repository": { |
@@ -9,1 +9,35 @@ # Cilly | ||
# Table of contents | ||
- [Installation](#installation) | ||
- [Basic usage](#basic-usage) | ||
- [Documentation](#documentation) | ||
- [Arguments](#arguments) | ||
- [Options](#options) | ||
- [Commands](#commands) | ||
- [Subcommands](#subcommands) | ||
- [Option inheritance](#option-inheritance) | ||
- [Validators](#validators) | ||
- [Hooks](#hooks) | ||
- [Generating documentation](#generating-documentation) | ||
- [Custom help handlers](#custom-help-handlers) | ||
- [Custom exception handling](#custom-exception-handling) | ||
# Installation | ||
``` | ||
npm install cilly | ||
``` | ||
# Basic usage | ||
# Documentation | ||
## Commands | ||
### Subcommands | ||
### Option inheritance | ||
## Arguments | ||
## Options | ||
## Validators | ||
## Hooks | ||
## Generating documentation | ||
## Custom help handlers | ||
## Custom exception handling | ||
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
43840
1021
43