mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 18:29:23 +02:00
29 lines
887 B
TypeScript
29 lines
887 B
TypeScript
export function buildArguments<T>(
|
|
commands: string[],
|
|
options: Partial<T> | undefined,
|
|
map: Partial<Record<keyof T, string>>,
|
|
): string[] {
|
|
const args = commands;
|
|
if (options) {
|
|
for (const [key, value] of Object.entries(options)) {
|
|
if (value) {
|
|
const option = map[key as keyof T];
|
|
if (option) {
|
|
args.push(option);
|
|
switch (typeof value) {
|
|
case "number":
|
|
args.push(value.toString());
|
|
break;
|
|
case "string":
|
|
args.push(value);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return args;
|
|
}
|
|
|
|
export type SingleUser = number | "current";
|
|
export type SingleUserOrAll = SingleUser | "all";
|