问题描述
我使用 commander 包作为 CLI 解析器。
commander
.command('command1 <parameter>' )
.description('description 1 goes here')
.command('command2 <parameter>' )
.description('description 2 goes here')
myprogram help
# Commands:
# command1 <parameter> description 1 goes here
# command2 <parameter> description 2 goes here
myprogram help command1
# command1 is used for...
#
# ... detailed description
#
# ...
解决方法
在包的作者帮助下弄清楚了。 .description()
可用于添加仅在常规 help
命令中显示的简短内联描述,而 .addHelpText()
可包含在特定命令帮助中显示的附加帮助测试,例如
commander
.command('hello')
.description('Shows greetings')
.addHelpText('after','\nGreets the world ....< long text goes here >')