0
試圖將yargs用於cli應用程序,並且遇到了我的位置參數問題。使用yargs自定義位置命令參數
我:
require('yargs')
.command(
'my-command <value>',
'This command does someting'
(y) => {
return y
.option('my-option', {
describe: "Some option",
demandOption: true
})
}
(args) => {
//execute my command here
}
)
.help()
.completion()
.argv
這讓我打電話:
my-program my-command my-value --my-option=hello!
而且args.value現在包含 「我的價值」。
到目前爲止這麼好。然而問題在於,'價值'的論點並沒有顯示在幫助文本中。我還想進一步限制值的參數,基本上添加一個選擇數組。但我只能找到如何使用產生 - 標誌的.option()函數來做到這一點。如--my選項。
是否可以像定製一個 - 選項一樣自定義位置參數?