Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit 2484d1e

Browse files
committed
fix: add help values to cache
1 parent 50334c4 commit 2484d1e

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"author": "Jeff Dickey @jdxcode",
66
"bugs": "https://github.com/anycli/command/issues",
77
"dependencies": {
8-
"@anycli/parser": "^3.0.2",
8+
"@anycli/parser": "^3.0.3",
99
"cli-ux": "^3.3.10",
1010
"debug": "^3.1.0",
1111
"lodash": "^4.17.4",
1212
"tslib": "^1.9.0"
1313
},
1414
"devDependencies": {
15-
"@anycli/config": "^0.2.6",
15+
"@anycli/config": "^0.2.8",
1616
"@anycli/tslint": "^0.2.1",
1717
"@commitlint/cli": "^6.0.5",
1818
"@commitlint/config-conventional": "^6.0.4",

src/cache.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ export function convertToCached(c: Config.ICommand, opts: ConvertToCachedOptions
1616
pluginName: opts.plugin && opts.plugin.name,
1717
hidden: c.hidden,
1818
aliases: c.aliases || [],
19-
// help: c.help,
20-
flags: _.mapValues(c.flags, (flag, name) => {
19+
flags: _.mapValues(c.flags || {}, (flag, name) => {
2120
if (flag.type === 'boolean') {
2221
return {
2322
name,
@@ -36,15 +35,18 @@ export function convertToCached(c: Config.ICommand, opts: ConvertToCachedOptions
3635
hidden: flag.hidden,
3736
required: flag.required,
3837
helpValue: flag.helpValue,
38+
options: flag.options,
39+
default: _.isFunction(flag.default) ? flag.default() : flag.default,
3940
}
4041
}),
41-
args: c.args.map(a => ({
42+
args: c.args ? c.args.map(a => ({
4243
name: a.name,
4344
description: a.description,
4445
required: a.required,
45-
// default: a.default && a.default(),
46+
options: a.options,
47+
default: _.isFunction(a.default) ? a.default() : a.default,
4648
hidden: a.hidden,
47-
})),
49+
})) : {} as Config.ICachedCommand['args'],
4850
load: async () => c,
4951
}
5052
}

test/command.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ describe('command', () => {
6363
hidden: true,
6464
required: false,
6565
description: 'flagb desc',
66+
options: ['a', 'b'],
67+
default: () => 'mydefault',
6668
}),
6769
}
6870
static args = [
@@ -71,6 +73,8 @@ describe('command', () => {
7173
description: 'arg1 desc',
7274
required: true,
7375
hidden: false,
76+
options: ['af', 'b'],
77+
default: () => 'myadefault',
7478
}
7579
]
7680
}.convertToCached({id: 'foo:bar'})
@@ -102,6 +106,8 @@ describe('command', () => {
102106
required: false,
103107
type: 'option',
104108
helpValue: undefined,
109+
default: 'mydefault',
110+
options: ['a', 'b'],
105111
}
106112
},
107113
args: [
@@ -110,6 +116,8 @@ describe('command', () => {
110116
name: 'arg1',
111117
hidden: false,
112118
required: true,
119+
options: ['af', 'b'],
120+
default: 'myadefault',
113121
}
114122
],
115123
})

yarn.lock

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# yarn lockfile v1
33

44

5-
"@anycli/config@^0.2.6":
6-
version "0.2.6"
7-
resolved "https://registry.yarnpkg.com/@anycli/config/-/config-0.2.6.tgz#d40709a61704907d4d6e7dcab6bbf124ab74e9ad"
5+
"@anycli/config@^0.2.8":
6+
version "0.2.8"
7+
resolved "https://registry.yarnpkg.com/@anycli/config/-/config-0.2.8.tgz#db2884692252f2f64afaf1e89cc507c2d35a3226"
88
dependencies:
99
cli-ux "^3.3.10"
1010
debug "^3.1.0"
@@ -13,9 +13,9 @@
1313
lodash "^4.17.4"
1414
read-pkg "^3.0.0"
1515

16-
"@anycli/parser@^3.0.2":
17-
version "3.0.2"
18-
resolved "https://registry.yarnpkg.com/@anycli/parser/-/parser-3.0.2.tgz#69af00b6b6f0cc6da4405cf44dc29b2d14d30c6e"
16+
"@anycli/parser@^3.0.3":
17+
version "3.0.3"
18+
resolved "https://registry.yarnpkg.com/@anycli/parser/-/parser-3.0.3.tgz#abc33c9098485d0ae2705eab859ff305aec6006f"
1919
dependencies:
2020
"@anycli/screen" "^0.0.3"
2121
chalk "^2.3.0"
@@ -556,8 +556,8 @@ content-type@^1.0.4:
556556
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
557557

558558
conventional-changelog-angular@^1.3.3:
559-
version "1.6.0"
560-
resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.0.tgz#0a26a071f2c9fcfcf2b86ba0cfbf6e6301b75bfa"
559+
version "1.6.1"
560+
resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.1.tgz#e1434d017c854032b272f690424a8c0ca16dc318"
561561
dependencies:
562562
compare-func "^1.3.1"
563563
q "^1.4.1"
@@ -1063,8 +1063,8 @@ global-dirs@^0.1.0:
10631063
ini "^1.3.4"
10641064

10651065
globals@^11.0.1:
1066-
version "11.2.0"
1067-
resolved "https://registry.yarnpkg.com/globals/-/globals-11.2.0.tgz#aa2ece052a787563ba70a3dcd9dc2eb8a9a0488c"
1066+
version "11.3.0"
1067+
resolved "https://registry.yarnpkg.com/globals/-/globals-11.3.0.tgz#e04fdb7b9796d8adac9c8f64c14837b2313378b0"
10681068

10691069
globby@^4.0.0:
10701070
version "4.1.0"

0 commit comments

Comments
 (0)