admin管理员组文章数量:1356560
I have the following code
export const program = new Command();
program.version('0.0.1');
program
mand('groups')
mand('create')
.action(() => console.log('creating'))
mand('delete')
.action(() => console.log('deleting-all'))
program.parse(process.argv)
What I want to achieve is something like
groups create
and groups delete
The code however chains that delete to the create. It recognizes groups create
and groups create delete
(which I dont want) but does not recognize the groups delete
I have the following code
export const program = new Command();
program.version('0.0.1');
program
.mand('groups')
.mand('create')
.action(() => console.log('creating'))
.mand('delete')
.action(() => console.log('deleting-all'))
program.parse(process.argv)
What I want to achieve is something like
groups create
and groups delete
The code however chains that delete to the create. It recognizes groups create
and groups create delete
(which I dont want) but does not recognize the groups delete
1 Answer
Reset to default 11You want to add the delete
submand to the groups
mand. e.g.
const { Command } = require('mander');
const program = new Command();
program.version('0.0.1');
const groups = program
.mand('groups');
groups
.mand('create')
.action(() => console.log('creating'))
groups
.mand('delete')
.action(() => console.log('deleting-all'))
program.parse(process.argv)
The related example file is: https://github./tj/mander.js/blob/master/examples/nestedCommands.js
本文标签: javascriptNested commands with commanderStack Overflow
版权声明:本文标题:javascript - Nested commands with commander - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744057146a2583461.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论