refactor: rewrite arg parsing

This commit is contained in:
Derrick Hammer 2023-07-07 09:52:03 -04:00
parent 2334cf73aa
commit 5a01ee6cec
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 3 deletions

View File

@ -445,10 +445,17 @@ export class Config {
} }
public parseArg(args: arg.Result<any>) { public parseArg(args: arg.Result<any>) {
const argPairs = args._.reduce((prev: any, item: any) => {
const parts = item.split("=");
const key = parts[0].replace("-", "");
prev[key] = parts[1];
return prev;
}, {});
// eslint-disable-next-line @typescript-eslint/no-for-in-array // eslint-disable-next-line @typescript-eslint/no-for-in-array
for (let key in args._) { for (const key of argPairs) {
let newKey = key.replace("-", ""); objectPath.set(this.data, key, argPairs[key]);
objectPath.set(this.data, newKey, args[key]);
} }
} }