-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replacing Command Line Args Module #125
Comments
Some way of auto-generating CLI help from the schema would be nice. If the user runs None of the available methods .toString, getSchema or getProperties even lists the arg keys. Hard to generate help from that? Ideas? |
@mlucool I'm not against adding support for command-line aliases, though I don't think it's that valuable because command-line args are already supported as long options. I fear it will make the code a bit more complex (and some parts are already too complex for easy maintenance I think). So I would rather avoid it, but it's not a definitive "No". What do other interested parties say? On the other hand I find @PCguru's idea of auto-generating-CLI-help far more easy to accept. This would not complicate the code, this would only add a new simple method. There is no code at the moment that returns the arg keys, but that should be very easy to develop. This is a nice idea for a PR for a wannabee contributor :-) Thanks to both of you for your ideas! |
I would really appreciate both command-line aliases and an auto-generated help message. As far as I can tell, convict currently uses optmist to parse the command line arguments. However optimist has been deprecated since February 2014. So maybe replacing optimist with something like commander would be a good idea anyways. |
The lack of short arguments is a pronounced deficiency. It's much more common to use short arguments (single hyphen) than to use the long form. convict is going way against the grain (esp in the Unix world) by only having support for long arguments. |
I'm not opposed to the idea of supporting short arguments. And now, with all the wonderful work of @elyscape and especially the 100% code coverage, we can serenely consider adding new features. As for the syntax, I would be more in favor of something like: help: {
short: 'h',
type: Boolean,
doc: 'Display this usage message',
default: false
}, Ideas, discussions welcome! |
How is the status on this issue? Would a PR with the new key |
With customGetter #313 you will be able to replace 'env' getter by your own getter/function. |
You will be able to do that with : const useArgOnlyOnce = false;
convict.addGetter('arg', function(value, schema, stopPropagation) {
const argv = parseArgs(this.getArgs(), {
configuration: {
'dot-notation': false
}
});
return schema._cvtCoerce(argv[value]);
}, useArgOnlyOnce, true); ;) |
In order to replace usage of something like https://www.npmjs.com/package/command-line-args it would be helpful to allow arg to have an alias. For example, I want -h and --help to both allow for help to be called.
Example usage:
On a related note, getSchemaString seems to print something like:
Any idea why it is mostly blank. Ideally, I'd like to see the output mirror https://www.npmjs.com/package/command-line-args#module_command-line-args--CommandLineArgs+getUsage
The text was updated successfully, but these errors were encountered: