I'm trying to load commands with the commandDir -- https://github.com/yargs/yargs/blob/HEAD/docs/advanced.md#example-command-hierarchy-using-commanddir -- but I'm being unsuccessful in _convincing_ yargs to pick on the example and epilogue that I'm adding in the config of the command. Would it also be possible to have a prologue?
Right now I have:
$ jsipfs files add --help
jsipfs files add <file>
Usage:
> jsipfs files add your-file.txt
Options:
--help Show help [boolean]
--trickle, -t Use the trickle DAG builder
[boolean] [default: false]
--recursive, -r [boolean] [default: false]
--wrap-with-directory, -w [boolean] [default: false]
--enable-sharding-experiment [boolean] [default: false]
--shard-split-threshold [default: 1000]
Ideally I would like to have:
禄 jsipfs files add --help
jsipfs files add <file>
Options:
--help Show help [boolean]
--trickle, -t Use the trickle DAG builder
[boolean] [default: false]
--recursive, -r [boolean] [default: false]
--wrap-with-directory, -w [boolean] [default: false]
--enable-sharding-experiment [boolean] [default: false]
--shard-split-threshold [default: 1000]
Examples:
> jsipfs files add your-file.txt
add your-file.txt to IPFS
> jsipfs files add -r your-directory
Description:
The add command will convert a file or files intro an IPLD graph...
Appreciate any help!
@diasdavid first off, sorry for the slow reply; the number of open-source issues I've been triaging these days have hit a bit of a head, and I've been dealing with some stressful life stuff to boot.
For starters, I've put together a yargs community slack which is a great place to go to get help, or to contribute features:
http://devtoolscommunity.herokuapp.com/
Now, I think we do support your use-case 馃憤 if you use the . builder exports, you should be able to define an example and epilog like so:
exports.builder = (yargs) {
yargs
.epilog('foo')
.example('bar')
}
Let me know if this does the trick for you 馃憤
I'm also struggling to get Epilogue to work using the .options() helper.
I know this is an ancient issue, but I figured I'd reply too.
const {
"output-json": outputJson,
"run-validations": validate,
"run-transforms": transformMessages,
"fail-duplicates": failOnDuplicates,
"max-violations": maxViolations,
} = yargs
.options({
"output-json": {
type: "boolean",
default: false,
description: `Produce a JSON Output of any discovered errors -> <root>${rootRelativePath(
config.jsonExtractMessagesLogPath
)}`,
},
"run-validations": {
type: "boolean",
default: true,
description:
"Validates messages according to apps/web/lang/config.<locale>.json, fail if messages don't validate.",
},
"run-transforms": {
type: "boolean",
default: true,
description:
"Transforms messages according to apps/web/lang/config.<locale>.json, fail on error.",
},
"fail-duplicates": {
type: "boolean",
default: true,
description: "If duplicate string-ids are found, fail-exit.",
},
"max-violations": {
type: "number",
default: 500,
requiresArg: true,
description: "Abort the script early after processing [max-violations]",
},
})
.version(false)
.scriptName("yarn build:translations")
.usage(
"$0 [options]",
"Snipped"
)
.epilogue("this string doesn't display")
.wrap(yargs.terminalWidth())
.help().argv;
Version: [email protected]
Workaround based on @bcoe's helpful comment!
.usage(
"$0 [options]",
"description",
(y: typeof yargs) => y.epilogue("My Epilogue")
)
(Note my example is TypeScript)
Most helpful comment
@diasdavid first off, sorry for the slow reply; the number of open-source issues I've been triaging these days have hit a bit of a head, and I've been dealing with some stressful life stuff to boot.
For starters, I've put together a yargs community slack which is a great place to go to get help, or to contribute features:
http://devtoolscommunity.herokuapp.com/
Now, I think we do support your use-case 馃憤 if you use the
. builderexports, you should be able to define an example and epilog like so:Let me know if this does the trick for you 馃憤