The following subcommand defined within the file litoria-generate.js script setup the usage
var program = require('commander'),
$ = require('../lib/litoria.js');
program
.description('generate html from the asciidoc file using html5 as backend')
.usage('litoria <generate> [options]')
.option('-b, --backend', 'backend - html5, docbook')
.parse(process.argv);
as such
.usage('litoria <generate> [options]')
But when I call the help for that subcommand, the usage is prefixed with the name of the file litoria-generate.
litoria generate --help
Usage: litoria-generate litoria <generate> [options]
Is there a workaround to only display for the subcommand the command defined within the subcommand usage ?
yep, it's kind of annoying that usage displays an invalid command.
My solutions was:
.usage('\n\n $ pm install <generate> [options]')
Then it displays like:
Usage: pm-install
$ pm install <generate> [options]
Options:
-h, --help output usage information
-f, --force force installation
Usage is prefixed with the name property of the command, which defaults to the file name. I created a PR to make this settable through a chainable function: https://github.com/tj/commander.js/pull/605
As a (hacky) workaround, you can currently just override _name, but you probably shouldn't rely on that, as it's not part of the intended API:
var program = require('commander');
program._name = 'litoria generate';
program
.description('generate html from the asciidoc file using html5 as backend')
.usage('litoria <generate> [options]')
.option('-b, --backend', 'backend - html5, docbook')
.parse(process.argv);
This issue should be closed as fixed with @CedricReichenbach's #605
@alexcanessa Thank you for the reminder!
Most helpful comment
Usage is prefixed with the name property of the command, which defaults to the file name. I created a PR to make this settable through a chainable function: https://github.com/tj/commander.js/pull/605
As a (hacky) workaround, you can currently just override
_name, but you probably shouldn't rely on that, as it's not part of the intended API: