mirror of
https://github.com/zhigang1992/now-deployment.git
synced 2026-06-15 02:09:11 +08:00
24 lines
440 B
TypeScript
24 lines
440 B
TypeScript
import arg from 'arg';
|
|
import getCommonArgs from './arg-common';
|
|
|
|
type ArgOptions = {
|
|
permissive?: boolean;
|
|
};
|
|
|
|
type Handler = (value: string) => any;
|
|
|
|
interface Spec {
|
|
[key: string]: string | Handler | [Handler];
|
|
}
|
|
|
|
export default function getArgs<T extends Spec>(
|
|
argv: string[],
|
|
argsOptions: T,
|
|
argOptions: ArgOptions = {}
|
|
) {
|
|
return arg(Object.assign({}, getCommonArgs(), argsOptions), {
|
|
...argOptions,
|
|
argv
|
|
});
|
|
}
|