@untool/yargs
Advanced tools
Comparing version
11
index.js
@@ -6,3 +6,3 @@ #!/usr/bin/env node | ||
const { bootstrap } = require('@untool/core'); | ||
const { initialize } = require('@untool/core'); | ||
@@ -16,3 +16,3 @@ const configure = (config, options) => ({ | ||
} | ||
const core = bootstrap(config, options); | ||
const core = initialize(config, options); | ||
const { registerCommands, handleArguments, handleError } = core; | ||
@@ -24,3 +24,3 @@ if (!(registerCommands && handleArguments && handleError)) { | ||
process.on('unhandledRejection', handleError); | ||
process.nextTick(() => | ||
process.nextTick(() => { | ||
registerCommands( | ||
@@ -35,4 +35,5 @@ yargs | ||
.check(handleArguments) | ||
).parse() | ||
); | ||
); | ||
yargs.parse(); | ||
}); | ||
} catch (error) { | ||
@@ -39,0 +40,0 @@ // eslint-disable-next-line no-console |
'use strict'; | ||
const { | ||
sync: { pipe, sequence, override }, | ||
sync: { sequence, override }, | ||
} = require('mixinable'); | ||
@@ -18,4 +18,4 @@ | ||
YargsMixin.strategies = { | ||
registerCommands: pipe, | ||
configureCommand: pipe, | ||
registerCommands: sequence, | ||
configureCommand: (...args) => sequence(...args) && args[1], | ||
handleArguments: sequence, | ||
@@ -22,0 +22,0 @@ handleError: override, |
{ | ||
"name": "@untool/yargs", | ||
"version": "0.26.0", | ||
"version": "1.0.0-rc.0", | ||
"description": "untool yargs mixin", | ||
@@ -27,4 +27,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@untool/core": "^0.26.0", | ||
"@untool/core": "^1.0.0-rc.0", | ||
"mixinable": "^4.0.0", | ||
"pretty-ms": "^4.0.0", | ||
"yargs": "^12.0.0" | ||
@@ -35,3 +36,3 @@ }, | ||
}, | ||
"gitHead": "0a63533a040db7b2bf27447320541510682b740f" | ||
"gitHead": "87b917a766013bab1caf2d312f3428e5dd329c12" | ||
} |
@@ -21,5 +21,5 @@ # `@untool/yargs` | ||
### `registerCommands(yargs)` ([pipe](https://github.com/untool/mixinable/blob/master/README.md#definepipe)) | ||
### `registerCommands(yargs)` ([sequence](https://github.com/untool/mixinable/blob/master/README.md#defineparallel)) | ||
This is the most relevant hook provided by `@untool/yargs`: it enables other mixins to register their respective commands. Implementations of this mixin method will receive two arguments: a [`yargs`](http://yargs.js.org) instance and the command line arguments `@untool/yargs` received. Implementations need to return the `yargs` instance that they were called with. | ||
This is the most relevant hook provided by `@untool/yargs`: it enables other mixins to register their respective commands. Implementations of this mixin method will receive a single argument: a [`yargs`](http://yargs.js.org) instance. | ||
@@ -31,3 +31,3 @@ ```javascript | ||
registerCommands(yargs) { | ||
return yargs.command( | ||
yargs.command( | ||
this.configureCommand({ | ||
@@ -43,3 +43,3 @@ command: 'foo', | ||
### `configureCommand(definition)` ([pipe](https://github.com/untool/mixinable/blob/master/README.md#definepipe)) | ||
### `configureCommand(definition)` ([sequence](https://github.com/untool/mixinable/blob/master/README.md#defineparallel)) | ||
@@ -61,3 +61,2 @@ By implemention this method, your mixin can intercept and alter command configuration. Its main purpose is to enable you to add arguments to commands defined by other mixins. | ||
} | ||
return definition; | ||
} | ||
@@ -64,0 +63,0 @@ }; |
15275
14.22%8
14.29%130
100%4
33.33%90
-1.1%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated