init
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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() )
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user