refactor: rewrite arg parsing
This commit is contained in:
parent
2334cf73aa
commit
5a01ee6cec
13
src/index.ts
13
src/index.ts
|
@ -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]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue