@magic/cli 0.0.43 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -58
- package/package.json +13 -13
- package/src/help/argToHelp.mjs +6 -1
- package/src/help/index.mjs +13 -1
- package/src/prompt.mjs +6 -4
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ provides autogenerated --help output (that can be customized)
|
|
|
11
11
|
handles commands and environment.
|
|
12
12
|
|
|
13
13
|
### v0.0.11+:
|
|
14
|
+
|
|
14
15
|
ecmascript modules only. no commonjs support.
|
|
15
16
|
|
|
16
17
|
[html-docs](https://magic.github.io/cli/)
|
|
@@ -35,49 +36,57 @@ ecmascript modules only. no commonjs support.
|
|
|
35
36
|
[snyk-image]: https://snyk.io/test/github/magic/cli/badge.svg
|
|
36
37
|
[snyk-url]: https://snyk.io/test/github/magic/cli
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
- [dependencies](#dependencies)
|
|
40
|
+
- [install](#install)
|
|
41
|
+
- [caveats](#caveats)
|
|
42
|
+
- [usage](#usage)
|
|
43
|
+
- [argv](#argv)
|
|
44
|
+
- [commands](#commands)
|
|
45
|
+
- [help](#help)
|
|
46
|
+
- [config](#configuration)
|
|
47
|
+
- [pure](#config-pure)
|
|
48
|
+
- [append / prepend](#prepend-append)
|
|
49
|
+
- [default](#default)
|
|
49
50
|
|
|
50
51
|
### <a name="dependencies"></a>dependencies:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
|
|
53
|
+
- [@magic/log](https://github.com/magic/log): console.log wrapper with loglevels
|
|
54
|
+
- [@magic/types](https://github.com/magic/types): type checking library
|
|
55
|
+
- [@magic/types](https://github.com/magic/cases): case checking library (CamelCase, snake_case, kebab-case)
|
|
54
56
|
|
|
55
57
|
@magic/log, @magic/cases and @magic/types have no dependencies.
|
|
56
58
|
|
|
57
59
|
### <a name="install"></a>install
|
|
60
|
+
|
|
58
61
|
be in a node ecmascript module project.
|
|
62
|
+
|
|
59
63
|
```bash
|
|
60
64
|
npm i --save-dev --save-exact @magic/cli
|
|
61
65
|
```
|
|
62
66
|
|
|
63
67
|
### <a name="caveats"></a>caveats
|
|
68
|
+
|
|
64
69
|
there are some quirks that need some careful consideration when designing a cli api
|
|
65
70
|
depending on your requirements, these caveats should seldomly apply.
|
|
66
71
|
|
|
67
72
|
##### last argument
|
|
73
|
+
|
|
68
74
|
if your last argument does not have a corresponding flag,
|
|
69
75
|
it will still be assigned to the last flag prior to it.
|
|
70
76
|
|
|
71
77
|
##### command name overload
|
|
78
|
+
|
|
72
79
|
if one of your options gets an argument that is equal to a command,
|
|
73
80
|
this command will be executed
|
|
74
81
|
|
|
75
82
|
##### flag name overload
|
|
83
|
+
|
|
76
84
|
cli arguments that start with a - will always be treated as flags, not values.
|
|
77
85
|
|
|
78
|
-
|
|
86
|
+
_those issues might get addressed in the future._
|
|
79
87
|
|
|
80
88
|
### <a name="usage"></a>Usage
|
|
89
|
+
|
|
81
90
|
first, define the cli file
|
|
82
91
|
|
|
83
92
|
```javascript
|
|
@@ -85,10 +94,7 @@ first, define the cli file
|
|
|
85
94
|
import { cli } from '@magic/cli'
|
|
86
95
|
|
|
87
96
|
const res = cli({
|
|
88
|
-
commands: [
|
|
89
|
-
['cmd1', 'cmd1alias'],
|
|
90
|
-
'cmd2',
|
|
91
|
-
],
|
|
97
|
+
commands: [['cmd1', 'cmd1alias'], 'cmd2'],
|
|
92
98
|
options: [
|
|
93
99
|
['--flag1', '-f1'],
|
|
94
100
|
['--flag2', '-f2'],
|
|
@@ -96,12 +102,8 @@ const res = cli({
|
|
|
96
102
|
default: {
|
|
97
103
|
'--default-key': 'default-value',
|
|
98
104
|
},
|
|
99
|
-
required: [
|
|
100
|
-
|
|
101
|
-
],
|
|
102
|
-
single: [
|
|
103
|
-
'--default-key',
|
|
104
|
-
],
|
|
105
|
+
required: ['--default-key'],
|
|
106
|
+
single: ['--default-key'],
|
|
105
107
|
env: [[['--production', '--prod', '--p', '-p'], 'NODE_ENV', 'production']],
|
|
106
108
|
pure: true, // do neither change process.argv nor process.env
|
|
107
109
|
pureArgv: true, // do not change process.argv
|
|
@@ -112,6 +114,7 @@ console.log(res)
|
|
|
112
114
|
```
|
|
113
115
|
|
|
114
116
|
### <a name="argv"></a>options / argv
|
|
117
|
+
|
|
115
118
|
argv mappings handle options and option aliases
|
|
116
119
|
|
|
117
120
|
using the cli file above
|
|
@@ -121,6 +124,7 @@ using the cli file above
|
|
|
121
124
|
```
|
|
122
125
|
|
|
123
126
|
resulting process.argv:
|
|
127
|
+
|
|
124
128
|
```javascript
|
|
125
129
|
process.argv = [
|
|
126
130
|
'/path/to/bin/node',
|
|
@@ -134,6 +138,7 @@ process.argv = [
|
|
|
134
138
|
```
|
|
135
139
|
|
|
136
140
|
logged javascript object
|
|
141
|
+
|
|
137
142
|
```javascript
|
|
138
143
|
{
|
|
139
144
|
argv: { '--flag1': ['arg1', arg2], '--flag2': [] },
|
|
@@ -143,7 +148,9 @@ logged javascript object
|
|
|
143
148
|
```
|
|
144
149
|
|
|
145
150
|
### <a name="commands"><a>commands
|
|
151
|
+
|
|
146
152
|
cli commands will be handled too.
|
|
153
|
+
|
|
147
154
|
```javascript
|
|
148
155
|
// call
|
|
149
156
|
./bin.js cmd1
|
|
@@ -156,9 +163,11 @@ cli commands will be handled too.
|
|
|
156
163
|
```
|
|
157
164
|
|
|
158
165
|
### <a name="help"></a>help output
|
|
166
|
+
|
|
159
167
|
@magic/cli will parse your configuration and create a help text based on it.
|
|
160
168
|
|
|
161
169
|
#### <a name="help-simple"></a>simple help message
|
|
170
|
+
|
|
162
171
|
```javascript
|
|
163
172
|
// ./bin.mjs
|
|
164
173
|
|
|
@@ -172,7 +181,6 @@ const args = {
|
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
const argv = cli(args)
|
|
175
|
-
|
|
176
184
|
```
|
|
177
185
|
|
|
178
186
|
then run ./bin.mjs without arguments
|
|
@@ -199,7 +207,9 @@ dev: set NODE_ENV to development - aliases ["development"]
|
|
|
199
207
|
```
|
|
200
208
|
|
|
201
209
|
#### <a name="help-detailed"></a>detailed help message
|
|
210
|
+
|
|
202
211
|
the help property will accept an object which maps to the args object
|
|
212
|
+
|
|
203
213
|
```javascript
|
|
204
214
|
import cli from '@magic/cli'
|
|
205
215
|
|
|
@@ -246,9 +256,11 @@ dev: set process.NODE_ENV to development - aliases ["development"]
|
|
|
246
256
|
```
|
|
247
257
|
|
|
248
258
|
### <a name="clean"></a>clean
|
|
259
|
+
|
|
249
260
|
some cli arguments will be expected to return a string instead of a list of arguments.
|
|
250
261
|
|
|
251
262
|
this can be achieved using the single array
|
|
263
|
+
|
|
252
264
|
```javascript
|
|
253
265
|
const args = {
|
|
254
266
|
options: [['--single', '-s']],
|
|
@@ -260,13 +272,14 @@ const res = cli(args)
|
|
|
260
272
|
console.log(res)
|
|
261
273
|
```
|
|
262
274
|
|
|
263
|
-
|
|
264
275
|
### <a name="required"></a>required
|
|
276
|
+
|
|
265
277
|
some cli arguments will be required.
|
|
266
278
|
|
|
267
279
|
this can be achieved using the required array.
|
|
268
280
|
|
|
269
281
|
if a required field is missing, a error message and the help will be shown.
|
|
282
|
+
|
|
270
283
|
```javascript
|
|
271
284
|
const args = {
|
|
272
285
|
options: [['--required', '-r']],
|
|
@@ -279,12 +292,14 @@ console.log(res)
|
|
|
279
292
|
```
|
|
280
293
|
|
|
281
294
|
### <a name="config"></a>configuration
|
|
295
|
+
|
|
282
296
|
there are some configuration parameters that can be passed to the cli function
|
|
283
297
|
|
|
284
298
|
#### <a name="config-pure"></a>pure
|
|
299
|
+
|
|
285
300
|
```javascript
|
|
286
301
|
const args = {
|
|
287
|
-
pure: false,
|
|
302
|
+
pure: false, // set to true to prevent changes to process.argv and process.env
|
|
288
303
|
pureEnv: false, // set to true to prevent changes to process.env
|
|
289
304
|
pureArgv: false, // set to true to prevent changes to process.argv
|
|
290
305
|
}
|
|
@@ -293,7 +308,9 @@ cli(args)
|
|
|
293
308
|
```
|
|
294
309
|
|
|
295
310
|
### <a name="prepend-append"></a>prepend/append
|
|
311
|
+
|
|
296
312
|
process.argv values can be prepended and appended
|
|
313
|
+
|
|
297
314
|
```javascript
|
|
298
315
|
import cli from '@magic/cli'
|
|
299
316
|
|
|
@@ -306,7 +323,9 @@ cli(args)
|
|
|
306
323
|
```
|
|
307
324
|
|
|
308
325
|
#### <a name="default"></a>default
|
|
326
|
+
|
|
309
327
|
use this to set default process.argv key: value pairs that should be set if they are not
|
|
328
|
+
|
|
310
329
|
```javascript
|
|
311
330
|
import cli from '@magic/cli'
|
|
312
331
|
|
|
@@ -332,148 +351,202 @@ const argv = cli(args)
|
|
|
332
351
|
### Changelog
|
|
333
352
|
|
|
334
353
|
##### 0.0.1
|
|
354
|
+
|
|
335
355
|
first release
|
|
336
356
|
|
|
337
357
|
##### 0.0.3
|
|
358
|
+
|
|
338
359
|
cli's should now correctly process.exit(1) on error of the spawned process.
|
|
339
360
|
|
|
340
361
|
##### 0.0.4
|
|
362
|
+
|
|
341
363
|
console help output now aligns nicely
|
|
342
364
|
|
|
343
365
|
##### 0.0.5
|
|
366
|
+
|
|
344
367
|
node 12.4.0 does not have --experimental-node-modules fladg.
|
|
345
368
|
|
|
346
369
|
##### 0.0.6
|
|
370
|
+
|
|
347
371
|
readd --experimental-node-modules flag for 13.1.0+
|
|
348
372
|
|
|
349
373
|
##### 0.0.7
|
|
374
|
+
|
|
350
375
|
update dependencies
|
|
351
376
|
bump node version
|
|
352
377
|
|
|
353
378
|
##### 0.0.8
|
|
379
|
+
|
|
354
380
|
help is shown if cli has commands but none are given
|
|
355
381
|
|
|
356
382
|
##### 0.0.9
|
|
383
|
+
|
|
357
384
|
update dependencies
|
|
358
385
|
|
|
359
386
|
##### 0.0.10
|
|
387
|
+
|
|
360
388
|
update dependencies
|
|
361
389
|
|
|
362
390
|
##### 0.0.11
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
391
|
+
|
|
392
|
+
- parsed.args added. is copy of argv, but using camelCased keys without leading --.
|
|
393
|
+
- no commonjs fallback, ecmascript modules all the way
|
|
394
|
+
- parsed does not return aliases. env, argv, args, commands. thats it.
|
|
366
395
|
|
|
367
396
|
##### 0.0.12
|
|
397
|
+
|
|
368
398
|
add @magic/cases dependency
|
|
369
399
|
|
|
370
400
|
##### 0.0.13
|
|
401
|
+
|
|
371
402
|
update deps
|
|
372
403
|
|
|
373
404
|
##### 0.0.14
|
|
405
|
+
|
|
374
406
|
--help works for cli scripts without commands too
|
|
375
407
|
|
|
376
408
|
##### 0.0.15
|
|
409
|
+
|
|
377
410
|
cli will always provide --help and -h flags to show help
|
|
378
411
|
|
|
379
412
|
##### 0.0.16
|
|
380
|
-
|
|
381
|
-
|
|
413
|
+
|
|
414
|
+
- args can be set to be single now, making them return a .join(' ')ed string instead of an array
|
|
415
|
+
- args can be set to be required now, making the cli error and show the help if they are not.
|
|
382
416
|
|
|
383
417
|
##### 0.0.17
|
|
418
|
+
|
|
384
419
|
required args can now be an array. this allows '--a' or '--b' to be required.
|
|
385
420
|
errors if both are given.
|
|
386
421
|
|
|
387
422
|
##### 0.0.18
|
|
388
|
-
|
|
389
|
-
|
|
423
|
+
|
|
424
|
+
- the command `cli-name all` now automagically sets all available commands to true.
|
|
425
|
+
- command keys will always be set to a boolean, return false if task is supposed to not be active.
|
|
390
426
|
|
|
391
427
|
##### 0.0.19
|
|
428
|
+
|
|
392
429
|
regression: calling cli that has commands without commands will show help again.
|
|
393
430
|
|
|
394
431
|
##### 0.0.20
|
|
432
|
+
|
|
395
433
|
regression: make commands only have keys for active commands again
|
|
396
434
|
|
|
397
435
|
##### 0.0.21
|
|
436
|
+
|
|
398
437
|
finally get rid of the command regressions
|
|
399
438
|
|
|
400
439
|
##### 0.0.22
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
440
|
+
|
|
441
|
+
- add cli.prompt to get user input.
|
|
442
|
+
- do not error if args.options is empty
|
|
443
|
+
- exec and spawn now are separate functions corresponding to node builtins
|
|
404
444
|
|
|
405
445
|
##### 0.0.23
|
|
406
|
-
|
|
446
|
+
|
|
447
|
+
- cli.prompt: change call signature, remove PasswordStream
|
|
407
448
|
|
|
408
449
|
##### 0.0.24
|
|
409
|
-
|
|
410
|
-
|
|
450
|
+
|
|
451
|
+
- fix required node version
|
|
452
|
+
- update dependencies
|
|
411
453
|
|
|
412
454
|
##### 0.0.25
|
|
413
|
-
|
|
414
|
-
|
|
455
|
+
|
|
456
|
+
- prompt now has a yesDefault option
|
|
457
|
+
- prompt will add y/N or Y/n to the prompt message if it is missing
|
|
415
458
|
|
|
416
459
|
##### 0.0.26
|
|
417
|
-
|
|
460
|
+
|
|
461
|
+
- default help arguments are now output by default.
|
|
418
462
|
|
|
419
463
|
##### 0.0.27
|
|
464
|
+
|
|
420
465
|
nicer output for prompt messages
|
|
421
466
|
|
|
422
467
|
##### 0.0.28
|
|
468
|
+
|
|
423
469
|
bump required node version to 14.2.0
|
|
424
470
|
|
|
425
471
|
##### 0.0.29
|
|
472
|
+
|
|
426
473
|
update dependencies
|
|
427
474
|
|
|
428
475
|
##### 0.0.30
|
|
429
|
-
|
|
476
|
+
|
|
477
|
+
- update dependencies
|
|
430
478
|
|
|
431
479
|
##### 0.0.31
|
|
432
|
-
|
|
433
|
-
|
|
480
|
+
|
|
481
|
+
- bump required node version to 14.15.4
|
|
482
|
+
- update dependencies
|
|
434
483
|
|
|
435
484
|
##### 0.0.32
|
|
485
|
+
|
|
436
486
|
update dependencies
|
|
437
487
|
|
|
438
488
|
##### 0.0.33
|
|
489
|
+
|
|
439
490
|
update dependencies
|
|
440
491
|
|
|
441
492
|
##### 0.0.34
|
|
493
|
+
|
|
442
494
|
update dependencies
|
|
443
495
|
|
|
444
496
|
##### 0.0.35
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
497
|
+
|
|
498
|
+
- parse now can get an opts object as third argument to overwrite child_process.exec options
|
|
499
|
+
- help.argToHelp now errors if the first argument is not an array, before errors only got triggered by falsy arg.
|
|
500
|
+
- exec now uses @magic/error for errors.
|
|
501
|
+
- exec does not trim() the result.
|
|
502
|
+
- findLongestString sorts by length and then alphabetically
|
|
503
|
+
- export execFile
|
|
504
|
+
- update dependencies
|
|
452
505
|
|
|
453
506
|
##### 0.0.36
|
|
507
|
+
|
|
454
508
|
update dependencies
|
|
455
509
|
|
|
456
510
|
##### 0.0.37
|
|
511
|
+
|
|
457
512
|
update dependencies
|
|
458
513
|
|
|
459
514
|
##### 0.0.38
|
|
515
|
+
|
|
460
516
|
update dependencies
|
|
461
517
|
|
|
462
518
|
##### 0.0.39
|
|
463
|
-
|
|
464
|
-
|
|
519
|
+
|
|
520
|
+
- update devdependencies
|
|
521
|
+
- parse.argv does not error if args do not have a length
|
|
465
522
|
|
|
466
523
|
##### 0.0.40
|
|
524
|
+
|
|
467
525
|
update dependencies
|
|
468
526
|
|
|
469
527
|
##### 0.0.41
|
|
528
|
+
|
|
470
529
|
update dependencies
|
|
471
530
|
|
|
472
531
|
##### 0.0.42
|
|
532
|
+
|
|
473
533
|
update dependencies
|
|
474
534
|
|
|
475
535
|
##### 0.0.43
|
|
536
|
+
|
|
476
537
|
update dependencies
|
|
477
538
|
|
|
478
|
-
##### 0.0.44
|
|
479
|
-
|
|
539
|
+
##### 0.0.44
|
|
540
|
+
|
|
541
|
+
- update dependencies
|
|
542
|
+
- add colors to default arg output
|
|
543
|
+
|
|
544
|
+
##### 0.0.45
|
|
545
|
+
|
|
546
|
+
- help.example can be an array
|
|
547
|
+
- update dependencies
|
|
548
|
+
- cli.prompt - msg can be an array
|
|
549
|
+
|
|
550
|
+
##### 0.0.46 - unreleased
|
|
551
|
+
|
|
552
|
+
- ...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"homepage": "https://magic.github.io/cli",
|
|
5
5
|
"description": "declarative command line interfaces with aliasing, commands and environment sanitization",
|
|
6
6
|
"scripts": {
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"declarative"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@magic/cases": "0.0.
|
|
36
|
-
"@magic/deep": "0.1.
|
|
37
|
-
"@magic/error": "0.0.
|
|
38
|
-
"@magic/log": "0.1.
|
|
39
|
-
"@magic/types": "0.1.
|
|
35
|
+
"@magic/cases": "0.0.9",
|
|
36
|
+
"@magic/deep": "0.1.16",
|
|
37
|
+
"@magic/error": "0.0.17",
|
|
38
|
+
"@magic/log": "0.1.18",
|
|
39
|
+
"@magic/types": "0.1.23"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@magic-modules/git-badges": "0.0.12",
|
|
43
|
-
"@magic-modules/light-switch": "0.0.
|
|
44
|
-
"@magic-modules/no-spy": "0.0.
|
|
45
|
-
"@magic-modules/pre": "0.0.
|
|
46
|
-
"@magic-themes/docs": "0.0.
|
|
47
|
-
"@magic/core": "0.0.
|
|
48
|
-
"@magic/format": "0.0.
|
|
49
|
-
"@magic/test": "0.2.
|
|
43
|
+
"@magic-modules/light-switch": "0.0.12",
|
|
44
|
+
"@magic-modules/no-spy": "0.0.9",
|
|
45
|
+
"@magic-modules/pre": "0.0.12",
|
|
46
|
+
"@magic-themes/docs": "0.0.15",
|
|
47
|
+
"@magic/core": "0.0.150",
|
|
48
|
+
"@magic/format": "0.0.51",
|
|
49
|
+
"@magic/test": "0.2.17"
|
|
50
50
|
},
|
|
51
51
|
"author": "Wizards & Witches",
|
|
52
52
|
"license": "AGPL-3.0",
|
package/src/help/argToHelp.mjs
CHANGED
|
@@ -39,7 +39,12 @@ export const argToHelp = (arr, help = {}, defaults = {}) => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (defaults[name]) {
|
|
42
|
-
|
|
42
|
+
let val = defaults[name]
|
|
43
|
+
if (is.string(val)) {
|
|
44
|
+
val = `'${val.replace(/'/gim, "'")}'`
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
res += ` - default: ${log.paint('green', val)}`
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
if (aliases.length) {
|
package/src/help/index.mjs
CHANGED
|
@@ -27,6 +27,18 @@ export const maybeHelp = args => {
|
|
|
27
27
|
const name = help.name || '@magic/cli wrapped cli.'
|
|
28
28
|
const header = is.string(help) ? help : help.text
|
|
29
29
|
|
|
30
|
+
const exampleArray = is.string(help.example) ? help.example.split('\n') : help.example
|
|
31
|
+
|
|
32
|
+
const exampleText = exampleArray
|
|
33
|
+
.map(a => {
|
|
34
|
+
if (a.trim().startsWith('#')) {
|
|
35
|
+
return log.color('green', a)
|
|
36
|
+
} else {
|
|
37
|
+
return a.trim()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
.join('\n')
|
|
41
|
+
|
|
30
42
|
const helpArray = [
|
|
31
43
|
log.paint('green', name),
|
|
32
44
|
'\n',
|
|
@@ -35,7 +47,7 @@ export const maybeHelp = args => {
|
|
|
35
47
|
options.length && `${log.paint('grey', 'flags')}:\n${optionHelp}\n\n`,
|
|
36
48
|
env.length && `${log.paint('grey', 'environment switches')}:\n${envHelp}\n\n`,
|
|
37
49
|
'examples:\n',
|
|
38
|
-
|
|
50
|
+
exampleText,
|
|
39
51
|
]
|
|
40
52
|
|
|
41
53
|
const errors = parsed.errors
|
package/src/prompt.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import is from '@magic/types'
|
|
2
2
|
import readline from 'readline'
|
|
3
3
|
|
|
4
|
-
import log from '@magic/log'
|
|
5
|
-
|
|
6
4
|
export const prompt = (msg = '', options = {}) =>
|
|
7
5
|
new Promise((resolve, reject) => {
|
|
8
|
-
const { yesNo = false,
|
|
6
|
+
const { yesNo = false, std = process, yesDefault = false } = options
|
|
7
|
+
|
|
8
|
+
if (is.array(msg)) {
|
|
9
|
+
msg = msg.join(' ')
|
|
10
|
+
}
|
|
9
11
|
|
|
10
12
|
if (yesNo) {
|
|
11
13
|
let flag = 'y/N'
|