CLI: get-config now supports masks
Massimo Melina committed
Jun 7, 2024 at 11:41 UTC
0bb19cf29886383f05d29295bd10abd91ca2d8f0
1 file changed
+7
-6
src/commands.ts
+7
-6
@@ -1,7 +1,7 @@
1
// This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3
import { createAdmin, getAccount, updateAccount } from './perm'
4
-import { getConfig, configKeyExists, setConfig } from './config'
4
+import { configKeyExists, setConfig, getWholeConfig } from './config'
5
import _ from 'lodash'
6
import { getUpdates, update } from './update'
7
import { openAdmin } from './listen'
@@ -11,6 +11,7 @@ import { createInterface } from 'readline'
11
import { getAvailablePlugins, mapPlugins, startPlugin, stopPlugin } from './plugins'
12
import { purgeFileAttr } from './fileAttr'
13
import { downloadPlugin } from './github'
14
+import { makeMatcher } from './cross'
15
16
if (!argv.updating)
17
try {
@@ -82,11 +83,11 @@ const commands = {
83
}
84
},
85
'get-config': {
85
- params: '<key>',
86
- cb(key: string) {
87
- if (!configKeyExists(key))
88
- throw "specified key doesn't exist"
89
- console.log(yaml.stringify(getConfig(key), { lineWidth:1000 }).trim())
86
+ params: '[<key-mask>]',
87
+ cb(key='*') {
88
+ const matcher = makeMatcher(key)
89
+ const filtered = _.pickBy(getWholeConfig({}), (v, k) => matcher(k))
90
+ console.log('\n' + yaml.stringify(filtered, { lineWidth:1000 }).trim())
91
}
92
},
93
quit: {