plsargs
Version:
😎 Another Argument Parser: But it's supports quotes!
36 lines (30 loc) • 693 B
text/typescript
export type TRawResult = {
_: Array<string>;
[key: string]: any;
}
export class Result {
raw: TRawResult = null;
constructor(raw: TRawResult) {
this.raw = raw;
}
has(key: string | number): boolean {
if (typeof key == "number") {
return this.raw._.hasOwnProperty(key);
} else {
return this.raw.hasOwnProperty(key);
}
}
get(key: string | number): string | undefined {
if (typeof key == "number") {
return this.raw._[key];
} else {
return this.raw[key];
}
}
get _(): string[] {
return this.raw._;
}
clone() {
return new Result({ ...this.raw, _: [ ...this.raw._ ]});
}
}