question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Demand option of nested config file parameters is not working

See original GitHub issue

The following example will always fail, if the parameter --foo.bar is not passed through a config file:

const args = require("yargs")
    .config("c")
    .options("foo.bar", {
        demandOption: true,
    })
    .argv;

console.log(args);

config.json:

{
    "foo": {
        "bar": "asdf"
    }
}

If demandOption is not set, the output is, as expected { _: [], c: 'config.json', foo: { bar: 'asdf' }, '$0': 'index.js' }. If it is set the following error is returned:

Missing required argument: foo.bar

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bcoecommented, Feb 24, 2021

@JoshMcCullough oh no worries, I didn’t take it as such.

I’ve just been dragging my feet on changes to object syntax, because I know if it was done on in a one off, feature by feature, implementation, we’d spend the next 5 years finding parts of the parser where we’d missed supporting it.

Need to figure out some sort of pre-processing step that hits everything at once.

1reaction
JoshMcCulloughcommented, Feb 24, 2021

Gotcha. My use of yargs is very limited, so I didn’t mean to trivialize this issue/fix, though I already realize that I did. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alamofire POST request with nested parameters returns ...
It is working with parameters that are not included any nested parameter. Normally, my url is working with following on the Google Chrome....
Read more >
Painless Configuration — Confuse 1.7.0 documentation
Environment Variables​​ Nested config values can be overridden by using a separator string in the environment variable name. By default, double underscores are ......
Read more >
How to handle large number of configuration parameters ...
I'm open for any suggestion or examples of a particular implementation. At the moment I'm experimenting with nested config variables, each ...
Read more >
Java agent configuration: Config file
New Relic's Java agent config settings for APM, including transaction tracer, errors, custom instrumentation, distributed tracing, system properties, etc.
Read more >
GitLab CI/CD include examples
Nested includes can include the same configuration file. ... the pipeline is created, so the following pipeline predefined variables are not available:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found