当我运行命令FirebaseOptions
时,终端仅显示add命令,而我定义了三个命令,所有这些命令均有效。当我使用node app.js --help
方法而不是parse()
时,为什么我会打印2次“删除便笺”?
argv
答案 0 :(得分:0)
您正在调用.argv
,这将在调用help
之前定义其他进程之前停止该过程。
从您创建的最后一个命令定义中删除.argv
是最简单的解决方法。
const yargs = require('yargs');
yargs.command({
command:'add',
describe:'Adds new note',
handler:function(){
console.log('Adding a note')
}
});
yargs.command({
command:'remove',
describe:'Removes a note',
handler:function(){
console.log('Removing a note')
}
});
yargs.command({
command:'list',
describe:'Fetches a list of notes',
handler:function(){
console.log('Fetching a list')
}
}).argv;