@samitouri / QOSami-HFS / commits / c219acff

allow duplicate keys in config.yaml to allow safer echo-appending shell command

Massimo Melina committed Oct 5, 2023 at 14:23 UTC c219acff50d86e29a84e42c8dad46b23747a4711
3 files changed +4 -4
config.md
+2 -2
@@ -31,8 +31,8 @@ Configuration can be done in several ways
31 - passing via command line at start in the form `--NAME VALUE`
32 - using envs in the form `HFS_NAME` (eg: `HFS_PORT`)
33 - directly editing the `config.yaml` file. As soon as you save it is reloaded and changes are applied
34 - - if you don't want to use an editor, consider typing this command inside the folder where the config file is:
35 - `echo "port: 1080" > config.yaml`. Be careful as it will overwrite the whole file.
34 + - if you don't want to use an editor, consider typing this (example) command inside the folder where the config file is:
35 + `echo "port: 1080" >> config.yaml`
36 - after HFS has started you can enter console command in the form `config NAME VALUE`
37
38 `NAME` stands for the property name that you want to change. See the complete list below.
src/config.ts
+1 -1
@@ -185,7 +185,7 @@ const saveDebounced = debounceAsync(async () => {
185 export const saveConfigAsap = () => void(saveDebounced())
186
187 console.log("config", filePath)
188 -const { save } = watchLoad(filePath, text => setConfig(yaml.parse(text)||{}, false), {
188 +const { save } = watchLoad(filePath, text => setConfig(yaml.parse(text, { uniqueKeys: false })||{}, false), {
189 failedOnFirstAttempt(){
190 console.log("No config file, using defaults")
191 setConfig({}, false)
src/listen.ts
+1 -1
@@ -196,7 +196,7 @@ export function startServer(srv: typeof httpSrv, { port, host }: StartServer) {
196 }
197 console.error(srv.name, srv.error)
198 const k = (srv === httpSrv? portCfg : httpsPortCfg).key()
199 - console.log(` >> try specifying a different port, enter this command: config ${k} 8011`)
199 + console.log(` >> try specifying a different port, enter this command: config ${k} 1080`)
200 resolve(0)
201 }
202 })