20 lines
481 B
JavaScript
20 lines
481 B
JavaScript
|
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() )
|
||
|
}
|
||
|
}
|