https://raw.githubusercontent.com/yargs/yargs/v15.4.1/docs/api.md
returns 404 for me
yargs
, that is really easy to use, supports subCommands (which is one of the thing why a lot of people use yargs), and it was intended to be testable by default.issue
why
"test mocha 'tests/**/*.test.js'"
in my package.json
. As far as I understand I can pass some custom params only like this npm run test -- --myCustomArg=foo
. Can I somehow shorten it to be script
--yargs
?
.option
on yargs
itself. It makes those options global and they exist on all sub-commands as well as the top-level executable. I do not want this behaviour. How do I accomplish this?
@ljharb I think you misunderstood. or I miss-explained. Consider the following example:
const yargs = require("yargs");
(async () => {
const options = await yargs
.option("config", {
type: "string",
alias: "c",
//global: false,
})
.command("hello", "description for hello command")
.demandCommand().argv;
console.log(options);
})();
When invoked like the following:
$ <program> hello --help
it's help output is:
<program> <command>
Commands:
<program> hello description for hello command
Options:
--help Show help [boolean]
--version Show version number [boolean]
-c, --config [string]
In my optinion the --config
options should not appear on the hello
command. As i understand it, this is documented as options being "global" by default. But setting global
to false
does not help.
Thanks for the help!
--version
option also exists on the sub-command. Which is not desireable.
--config
on everything?
global: true
doesn't mean this, what it means is that it will be hoisted above middleware. everything is global:false by default)
.hide('config')
or something