mirror of
https://github.com/zhigang1992/now-deployment.git
synced 2026-04-05 22:38:14 +08:00
20 lines
417 B
TypeScript
20 lines
417 B
TypeScript
type CommandConfig = {
|
|
[command: string]: string[];
|
|
};
|
|
|
|
export default function getSubcommand(
|
|
cliArgs: string[],
|
|
config: CommandConfig
|
|
) {
|
|
const [subcommand, ...rest] = cliArgs;
|
|
for (const k of Object.keys(config)) {
|
|
if (k !== 'default' && config[k].indexOf(subcommand) !== -1) {
|
|
return { subcommand: k, args: rest };
|
|
}
|
|
}
|
|
return {
|
|
subcommand: config.default,
|
|
args: cliArgs
|
|
};
|
|
}
|