@magic/cli 0.0.44 → 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 +8 -2
- package/package.json +8 -8
- package/src/help/index.mjs +13 -1
- package/src/prompt.mjs +6 -4
package/README.md
CHANGED
|
@@ -541,6 +541,12 @@ update dependencies
|
|
|
541
541
|
- update dependencies
|
|
542
542
|
- add colors to default arg output
|
|
543
543
|
|
|
544
|
-
##### 0.0.45
|
|
544
|
+
##### 0.0.45
|
|
545
545
|
|
|
546
|
-
|
|
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": {
|
|
@@ -40,13 +40,13 @@
|
|
|
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/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'
|