In our code we use commands and "subcommands", calling our tool via iobroker object will result in our code processing the command and then calling yargs.showHelp(), the generated output looks like:
iob object
Unknown command "object undefined"!
iobroker object
Object management
Commands:
iobroker get <id> Get object specified by id
...
...
...
I would expect, that it shows iobroker object get <id> and not iobroker get <id> as it is done when I call iobroker object --help:
moritz@moritz-ThinkPad-E470:~/workspaces/ioBroker.js-controller$ iob object --help
iobroker object
Object management
Commands:
iobroker object get <id> Get object specified by id
...
...
...
Why is there a difference, is this intended? If yes, how can I achieve the desired output via showHelp()?
You can find the relevant code here: https://github.com/ioBroker/ioBroker.js-controller/blob/12a235299be58d7bb4592d71d61478afe9f1797b/lib/setup.js#L34-L370
@foxriver76 in the version of yargs on master (_not yet released to npm_), we've added a method await getHelp() which will return a help string to you.
Could you try this out, and see if it gives you appropriate output? my hope was that this would make the use case of outputting help programmatically easier. I did also fix some bugs with showHelp() in the process, so I'd try both.
Hey, thanks for your reply.
I've installed 17.0.0-candidate.0 from GitHub, unfortunately this does not change the behavior. Also
const test = await yargs.getHelp();
console.log(test);
is printing the output w/o the desired object keyword. There has to be a difference between calling getHelp (and showHelp) and giving the output via --help flag. As mentioend above, using --help flag outputs the help correctly.
@foxriver76 could you please try npm i [email protected], I believe I figured out a fix.
Sorry for the delayed reply, unfortunately, the inconsistencies remain the same.
Most helpful comment
Hey, thanks for your reply.
I've installed
17.0.0-candidate.0from GitHub, unfortunately this does not change the behavior. Alsois printing the output w/o the desired
objectkeyword. There has to be a difference between callinggetHelp(andshowHelp) and giving the output via--helpflag. As mentioend above, using--helpflag outputs the help correctly.