@magic/cli
Advanced tools
Comparing version 0.0.43 to 0.0.44
{ | ||
"name": "@magic/cli", | ||
"version": "0.0.43", | ||
"version": "0.0.44", | ||
"homepage": "https://magic.github.io/cli", | ||
@@ -35,7 +35,7 @@ "description": "declarative command line interfaces with aliasing, commands and environment sanitization", | ||
"dependencies": { | ||
"@magic/cases": "0.0.8", | ||
"@magic/deep": "0.1.15", | ||
"@magic/error": "0.0.16", | ||
"@magic/log": "0.1.17", | ||
"@magic/types": "0.1.22" | ||
"@magic/cases": "0.0.9", | ||
"@magic/deep": "0.1.16", | ||
"@magic/error": "0.0.17", | ||
"@magic/log": "0.1.18", | ||
"@magic/types": "0.1.23" | ||
}, | ||
@@ -45,8 +45,8 @@ "devDependencies": { | ||
"@magic-modules/light-switch": "0.0.11", | ||
"@magic-modules/no-spy": "0.0.7", | ||
"@magic-modules/no-spy": "0.0.8", | ||
"@magic-modules/pre": "0.0.11", | ||
"@magic-themes/docs": "0.0.14", | ||
"@magic/core": "0.0.142", | ||
"@magic/format": "0.0.41", | ||
"@magic/test": "0.2.12" | ||
"@magic/core": "0.0.149", | ||
"@magic/format": "0.0.50", | ||
"@magic/test": "0.2.15" | ||
}, | ||
@@ -53,0 +53,0 @@ "author": "Wizards & Witches", |
181
README.md
@@ -14,2 +14,3 @@ ## @magic/cli | ||
### v0.0.11+: | ||
ecmascript modules only. no commonjs support. | ||
@@ -39,23 +40,26 @@ | ||
* [dependencies](#dependencies) | ||
* [install](#install) | ||
* [caveats](#caveats) | ||
* [usage](#usage) | ||
* [argv](#argv) | ||
* [commands](#commands) | ||
* [help](#help) | ||
* [config](#configuration) | ||
* [pure](#config-pure) | ||
* [append / prepend](#prepend-append) | ||
* [default](#default) | ||
- [dependencies](#dependencies) | ||
- [install](#install) | ||
- [caveats](#caveats) | ||
- [usage](#usage) | ||
- [argv](#argv) | ||
- [commands](#commands) | ||
- [help](#help) | ||
- [config](#configuration) | ||
- [pure](#config-pure) | ||
- [append / prepend](#prepend-append) | ||
- [default](#default) | ||
### <a name="dependencies"></a>dependencies: | ||
* [@magic/log](https://github.com/magic/log): console.log wrapper with loglevels | ||
* [@magic/types](https://github.com/magic/types): type checking library | ||
* [@magic/types](https://github.com/magic/cases): case checking library (CamelCase, snake_case, kebab-case) | ||
- [@magic/log](https://github.com/magic/log): console.log wrapper with loglevels | ||
- [@magic/types](https://github.com/magic/types): type checking library | ||
- [@magic/types](https://github.com/magic/cases): case checking library (CamelCase, snake_case, kebab-case) | ||
@magic/log, @magic/cases and @magic/types have no dependencies. | ||
### <a name="install"></a>install | ||
be in a node ecmascript module project. | ||
```bash | ||
@@ -66,2 +70,3 @@ npm i --save-dev --save-exact @magic/cli | ||
### <a name="caveats"></a>caveats | ||
there are some quirks that need some careful consideration when designing a cli api | ||
@@ -71,2 +76,3 @@ depending on your requirements, these caveats should seldomly apply. | ||
##### last argument | ||
if your last argument does not have a corresponding flag, | ||
@@ -76,2 +82,3 @@ it will still be assigned to the last flag prior to it. | ||
##### command name overload | ||
if one of your options gets an argument that is equal to a command, | ||
@@ -81,7 +88,9 @@ this command will be executed | ||
##### flag name overload | ||
cli arguments that start with a - will always be treated as flags, not values. | ||
*those issues might get addressed in the future.* | ||
_those issues might get addressed in the future._ | ||
### <a name="usage"></a>Usage | ||
first, define the cli file | ||
@@ -94,6 +103,3 @@ | ||
const res = cli({ | ||
commands: [ | ||
['cmd1', 'cmd1alias'], | ||
'cmd2', | ||
], | ||
commands: [['cmd1', 'cmd1alias'], 'cmd2'], | ||
options: [ | ||
@@ -106,8 +112,4 @@ ['--flag1', '-f1'], | ||
}, | ||
required: [ | ||
'--default-key', | ||
], | ||
single: [ | ||
'--default-key', | ||
], | ||
required: ['--default-key'], | ||
single: ['--default-key'], | ||
env: [[['--production', '--prod', '--p', '-p'], 'NODE_ENV', 'production']], | ||
@@ -123,2 +125,3 @@ pure: true, // do neither change process.argv nor process.env | ||
### <a name="argv"></a>options / argv | ||
argv mappings handle options and option aliases | ||
@@ -133,2 +136,3 @@ | ||
resulting process.argv: | ||
```javascript | ||
@@ -147,2 +151,3 @@ process.argv = [ | ||
logged javascript object | ||
```javascript | ||
@@ -157,3 +162,5 @@ { | ||
### <a name="commands"><a>commands | ||
cli commands will be handled too. | ||
```javascript | ||
@@ -171,5 +178,7 @@ // call | ||
### <a name="help"></a>help output | ||
@magic/cli will parse your configuration and create a help text based on it. | ||
#### <a name="help-simple"></a>simple help message | ||
```javascript | ||
@@ -188,3 +197,2 @@ // ./bin.mjs | ||
const argv = cli(args) | ||
``` | ||
@@ -216,3 +224,5 @@ | ||
#### <a name="help-detailed"></a>detailed help message | ||
the help property will accept an object which maps to the args object | ||
```javascript | ||
@@ -264,5 +274,7 @@ import cli from '@magic/cli' | ||
### <a name="clean"></a>clean | ||
some cli arguments will be expected to return a string instead of a list of arguments. | ||
this can be achieved using the single array | ||
```javascript | ||
@@ -279,4 +291,4 @@ const args = { | ||
### <a name="required"></a>required | ||
### <a name="required"></a>required | ||
some cli arguments will be required. | ||
@@ -287,2 +299,3 @@ | ||
if a required field is missing, a error message and the help will be shown. | ||
```javascript | ||
@@ -300,8 +313,10 @@ const args = { | ||
### <a name="config"></a>configuration | ||
there are some configuration parameters that can be passed to the cli function | ||
#### <a name="config-pure"></a>pure | ||
```javascript | ||
const args = { | ||
pure: false, // set to true to prevent changes to process.argv and process.env | ||
pure: false, // set to true to prevent changes to process.argv and process.env | ||
pureEnv: false, // set to true to prevent changes to process.env | ||
@@ -315,3 +330,5 @@ pureArgv: false, // set to true to prevent changes to process.argv | ||
### <a name="prepend-append"></a>prepend/append | ||
process.argv values can be prepended and appended | ||
```javascript | ||
@@ -329,3 +346,5 @@ import cli from '@magic/cli' | ||
#### <a name="default"></a>default | ||
use this to set default process.argv key: value pairs that should be set if they are not | ||
```javascript | ||
@@ -356,17 +375,23 @@ import cli from '@magic/cli' | ||
##### 0.0.1 | ||
first release | ||
##### 0.0.3 | ||
cli's should now correctly process.exit(1) on error of the spawned process. | ||
##### 0.0.4 | ||
console help output now aligns nicely | ||
##### 0.0.5 | ||
node 12.4.0 does not have --experimental-node-modules fladg. | ||
##### 0.0.6 | ||
readd --experimental-node-modules flag for 13.1.0+ | ||
##### 0.0.7 | ||
update dependencies | ||
@@ -376,32 +401,42 @@ bump node version | ||
##### 0.0.8 | ||
help is shown if cli has commands but none are given | ||
##### 0.0.9 | ||
update dependencies | ||
##### 0.0.10 | ||
update dependencies | ||
##### 0.0.11 | ||
* parsed.args added. is copy of argv, but using camelCased keys without leading --. | ||
* no commonjs fallback, ecmascript modules all the way | ||
* parsed does not return aliases. env, argv, args, commands. thats it. | ||
- parsed.args added. is copy of argv, but using camelCased keys without leading --. | ||
- no commonjs fallback, ecmascript modules all the way | ||
- parsed does not return aliases. env, argv, args, commands. thats it. | ||
##### 0.0.12 | ||
add @magic/cases dependency | ||
##### 0.0.13 | ||
update deps | ||
##### 0.0.14 | ||
--help works for cli scripts without commands too | ||
##### 0.0.15 | ||
cli will always provide --help and -h flags to show help | ||
##### 0.0.16 | ||
* args can be set to be single now, making them return a .join(' ')ed string instead of an array | ||
* args can be set to be required now, making the cli error and show the help if they are not. | ||
- args can be set to be single now, making them return a .join(' ')ed string instead of an array | ||
- args can be set to be required now, making the cli error and show the help if they are not. | ||
##### 0.0.17 | ||
required args can now be an array. this allows '--a' or '--b' to be required. | ||
@@ -411,93 +446,125 @@ errors if both are given. | ||
##### 0.0.18 | ||
* the command `cli-name all` now automagically sets all available commands to true. | ||
* command keys will always be set to a boolean, return false if task is supposed to not be active. | ||
- the command `cli-name all` now automagically sets all available commands to true. | ||
- command keys will always be set to a boolean, return false if task is supposed to not be active. | ||
##### 0.0.19 | ||
regression: calling cli that has commands without commands will show help again. | ||
##### 0.0.20 | ||
regression: make commands only have keys for active commands again | ||
##### 0.0.21 | ||
finally get rid of the command regressions | ||
##### 0.0.22 | ||
* add cli.prompt to get user input. | ||
* do not error if args.options is empty | ||
* exec and spawn now are separate functions corresponding to node builtins | ||
- add cli.prompt to get user input. | ||
- do not error if args.options is empty | ||
- exec and spawn now are separate functions corresponding to node builtins | ||
##### 0.0.23 | ||
* cli.prompt: change call signature, remove PasswordStream | ||
- cli.prompt: change call signature, remove PasswordStream | ||
##### 0.0.24 | ||
* fix required node version | ||
* update dependencies | ||
- fix required node version | ||
- update dependencies | ||
##### 0.0.25 | ||
* prompt now has a yesDefault option | ||
* prompt will add y/N or Y/n to the prompt message if it is missing | ||
- prompt now has a yesDefault option | ||
- prompt will add y/N or Y/n to the prompt message if it is missing | ||
##### 0.0.26 | ||
* default help arguments are now output by default. | ||
- default help arguments are now output by default. | ||
##### 0.0.27 | ||
nicer output for prompt messages | ||
##### 0.0.28 | ||
bump required node version to 14.2.0 | ||
##### 0.0.29 | ||
update dependencies | ||
##### 0.0.30 | ||
* update dependencies | ||
- update dependencies | ||
##### 0.0.31 | ||
* bump required node version to 14.15.4 | ||
* update dependencies | ||
- bump required node version to 14.15.4 | ||
- update dependencies | ||
##### 0.0.32 | ||
update dependencies | ||
##### 0.0.33 | ||
update dependencies | ||
##### 0.0.34 | ||
update dependencies | ||
##### 0.0.35 | ||
* parse now can get an opts object as third argument to overwrite child_process.exec options | ||
* help.argToHelp now errors if the first argument is not an array, before errors only got triggered by falsy arg. | ||
* exec now uses @magic/error for errors. | ||
* exec does not trim() the result. | ||
* findLongestString sorts by length and then alphabetically | ||
* export execFile | ||
* update dependencies | ||
- parse now can get an opts object as third argument to overwrite child_process.exec options | ||
- help.argToHelp now errors if the first argument is not an array, before errors only got triggered by falsy arg. | ||
- exec now uses @magic/error for errors. | ||
- exec does not trim() the result. | ||
- findLongestString sorts by length and then alphabetically | ||
- export execFile | ||
- update dependencies | ||
##### 0.0.36 | ||
update dependencies | ||
##### 0.0.37 | ||
update dependencies | ||
##### 0.0.38 | ||
update dependencies | ||
##### 0.0.39 | ||
* update devdependencies | ||
* parse.argv does not error if args do not have a length | ||
- update devdependencies | ||
- parse.argv does not error if args do not have a length | ||
##### 0.0.40 | ||
update dependencies | ||
##### 0.0.41 | ||
update dependencies | ||
##### 0.0.42 | ||
update dependencies | ||
##### 0.0.43 | ||
update dependencies | ||
##### 0.0.44 - unreleased | ||
##### 0.0.44 | ||
- update dependencies | ||
- add colors to default arg output | ||
##### 0.0.45 - unreleased | ||
... |
Sorry, the diff of this file is not supported yet
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
59806
470
547
+ Added@magic/cases@0.0.9(transitive)
+ Added@magic/deep@0.1.16(transitive)
+ Added@magic/error@0.0.17(transitive)
+ Added@magic/log@0.1.18(transitive)
+ Added@magic/types@0.1.23(transitive)
- Removed@magic/cases@0.0.8(transitive)
- Removed@magic/deep@0.1.15(transitive)
- Removed@magic/error@0.0.16(transitive)
- Removed@magic/log@0.1.17(transitive)
- Removed@magic/types@0.1.22(transitive)
Updated@magic/cases@0.0.9
Updated@magic/deep@0.1.16
Updated@magic/error@0.0.17
Updated@magic/log@0.1.18
Updated@magic/types@0.1.23