bandersnatch
Advanced tools
Comparing version 1.8.4 to 1.9.0
@@ -0,1 +1,8 @@ | ||
# [1.9.0](https://github.com/hongaar/bandersnatch/compare/v1.8.4...v1.9.0) (2021-10-25) | ||
### Features | ||
* add option to pass yargs parserConfiguration ([#334](https://github.com/hongaar/bandersnatch/issues/334)) ([9a19c98](https://github.com/hongaar/bandersnatch/commit/9a19c983058b0d3598d8a07015fa69a788906d84)) | ||
## [1.8.4](https://github.com/hongaar/bandersnatch/compare/v1.8.3...v1.8.4) (2021-10-14) | ||
@@ -2,0 +9,0 @@ |
@@ -18,3 +18,5 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
const yargs = this.program.createYargsInstance(); | ||
// We need to override 'strip-dashed' to make sure yargs can find the | ||
// '--get-yargs-completions' option. | ||
const yargs = this.program.createYargsInstance({ 'strip-dashed': false }); | ||
// yargs.getCompletion() doesn't work for our use case. | ||
@@ -21,0 +23,0 @@ yargs.parse(['$0', '--get-yargs-completions', '$0', ...argv], {}, (err, argv, output) => { |
import TypedEventEmitter from 'typed-emitter'; | ||
import { Argv } from 'yargs'; | ||
import { Argv, ParserConfigurationOptions } from 'yargs'; | ||
import { Command } from './command'; | ||
@@ -54,2 +54,9 @@ import { Repl } from './repl'; | ||
exit?: boolean | (() => void); | ||
/** | ||
* Pass Yargs parser configuration, for available options, see | ||
* https://github.com/yargs/yargs/blob/main/docs/advanced.md#customizing-yargs-parser. | ||
* | ||
* Defaults to `undefined`. | ||
*/ | ||
parserConfiguration?: Partial<ParserConfigurationOptions>; | ||
}; | ||
@@ -81,3 +88,3 @@ /** | ||
*/ | ||
createYargsInstance(): Argv<{}>; | ||
createYargsInstance(overrideParserConfiguration?: Partial<ParserConfigurationOptions>): Argv<{}>; | ||
/** | ||
@@ -84,0 +91,0 @@ * Adds a new command to the program. |
@@ -69,4 +69,4 @@ "use strict"; | ||
*/ | ||
createYargsInstance() { | ||
const yargs = (0, yargs_1.default)(); | ||
createYargsInstance(overrideParserConfiguration) { | ||
let yargs = (0, yargs_1.default)(); | ||
this.options.description && yargs.usage(this.options.description); | ||
@@ -77,2 +77,6 @@ // Help accepts boolean | ||
this.options.version !== false ? yargs.version() : yargs.version(false); | ||
// Pass yargs parser options if defined | ||
if (typeof this.options.parserConfiguration !== 'undefined') { | ||
yargs = yargs.parserConfiguration(Object.assign(Object.assign({}, this.options.parserConfiguration), overrideParserConfiguration)); | ||
} | ||
// Non-configurable options | ||
@@ -79,0 +83,0 @@ yargs.recommendCommands(); |
{ | ||
"name": "bandersnatch", | ||
"description": "Simple TypeScript CLI / REPL framework", | ||
"version": "1.8.4", | ||
"version": "1.9.0", | ||
"repository": { | ||
@@ -53,11 +53,11 @@ "type": "git", | ||
"doctoc": "2.1.0", | ||
"husky": "7.0.2", | ||
"jest": "27.2.5", | ||
"husky": "7.0.4", | ||
"jest": "27.3.1", | ||
"leasot": "12.0.0", | ||
"mock-argv": "2.0.6", | ||
"prettier": "2.4.1", | ||
"ts-jest": "27.0.5", | ||
"ts-node": "10.3.0", | ||
"ts-jest": "27.0.7", | ||
"ts-node": "10.4.0", | ||
"typescript": "4.4.4" | ||
} | ||
} |
@@ -378,7 +378,10 @@ # bandersnatch | ||
program which displays program version from package.json. | ||
- `historyFile` (string | null, defaults: {homedir}/.bandersnatch_history) is a | ||
- `historyFile` (string | null, default: {homedir}/.bandersnatch_history) is a | ||
path to the app history file. Set to NULL to disable. | ||
- `exit` (boolean | () => void, default: () => process.exit()) Specifies whether to add a default behaviour for an `exit` | ||
command. `false` disables the default implementation, a custom function will be installed | ||
as the actual handler. | ||
- `exit` (boolean | () => void, default: () => process.exit()) Specifies whether | ||
to add a default behaviour for an `exit` command. `false` disables the default | ||
implementation, a custom function will be installed as the actual handler. | ||
- `parserConfiguration` (object, optional) can be used to modify the parser | ||
configuration. For available options, see | ||
- https://github.com/yargs/yargs/blob/main/docs/api.md#parserConfiguration. | ||
@@ -385,0 +388,0 @@ #### `program.description(description)` |
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
84210
1348
769