kit.program/argv/test.js

20 lines
481 B
JavaScript
Raw Normal View History

2024-02-27 08:54:41 +00:00
const { CliCmdParser } = require("./index")
const parser = new CliCmdParser("测试程序");
parser.addCmdLine("config <key> [value]", "查询/设置配置");
parser.addCmdLine("killport <port>", "释放端口", function (params) {
console.log("killport", params)
});
let cmd = parser.parse(process.argv.slice(2))
if ( ! cmd ) {
console.log( parser.help() )
} else {
if ( cmd.canEval() ){
cmd.eval()
} else {
console.log( parser.help() )
}
}