indexzero / nconf

Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging.
https://github.com/indexzero/nconf
MIT License
3.87k stars 252 forks source link

Unable to call argv.showHelp to show argv usage #275

Open Telokis opened 6 years ago

Telokis commented 6 years ago

I am trying to call argv.showHelp in order to display which arguments are available to the user.

However, if I do nconf.argv().showHelp(); it crashes.

I tried reading the source code and I really expect this to work but it won't.

mhamann commented 6 years ago

nconf.argv() returns an instance of nconf so you can chain calls together.

You can access the help via nconf.argv().stores.argv.showHelp(); however, this is designed to be handled by a formatter, so the results may not be terribly useful to you.

Telokis commented 6 years ago

Could it be possible for nconf to accept an optional usage argument/option to be passed to yargs so that yargs can automatically handle --help?

mhamann commented 6 years ago

@Telokis sounds like that could be a good enhancement. Why not take a look at the source and submit a PR?