|
|
|
@ -15,7 +15,7 @@ function getArgs (startIndex = 1) {
|
|
|
|
|
args[longArgFlag] = longArgValue; |
|
|
|
|
// flags
|
|
|
|
|
} else if (arg[0] === '-') { |
|
|
|
|
const flags = arg.slice(1, arg.length).split(''); |
|
|
|
|
const flags = arg.slice(1, arg.length); |
|
|
|
|
args[flags] = true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -27,10 +27,12 @@ const cmds = new Map([
|
|
|
|
|
['worker', workerCmd], |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
const startIndex = process.argv.findIndex(argv => argv === 'fui-cli'); |
|
|
|
|
const baseCmd = 'fui-cli'; |
|
|
|
|
|
|
|
|
|
const startIndex = process.argv.findIndex(argv => argv.indexOf(baseCmd) !== -1); |
|
|
|
|
|
|
|
|
|
if (startIndex === -1) { |
|
|
|
|
throw new Error('commad not found'); |
|
|
|
|
throw new Error(`Command ${baseCmd} not found in args`); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const cmd = process.argv[startIndex + 1]; |
|
|
|
@ -38,5 +40,5 @@ const cmd = process.argv[startIndex + 1];
|
|
|
|
|
if (cmds.has(cmd)) { |
|
|
|
|
cmds.get(cmd)?.exec(getArgs(startIndex + 2)); |
|
|
|
|
} else { |
|
|
|
|
throw new Error('命令不存在'); |
|
|
|
|
throw new Error(`Command ${cmd} not supported`); |
|
|
|
|
} |
|
|
|
|