-
Notifications
You must be signed in to change notification settings - Fork 18
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
Override config file option value with option parameter #25
Comments
This is a bug
This was complicated by the fact the path to the configuration file can a
flag. So to fix this, we need to parse flags over a dummy struct, config
file flag? Then parse config over real struct , then parse flags over real
struct
…On Mon, 28 Oct 2019 at 6:54 pm VonC ***@***.***> wrote:
The "Features with examples
<https://github.com/jpillora/opts/blob/8ed9e9c54b865d3d47b939b24b672a1355cd375a/README.md#features-with-examples>"
sections includes:
Default values from a JSON config file, unmarshalled via your config struct
It refers to eg-config
<https://github.com/jpillora/opts-examples/tree/559c3c9618b03835f19897973946c1afa775f2d0/eg-config>,
which shows the program returns the config file *default* value, *even
when the command-line option specifies a different value*.
$ config --bar moon
hello
world
Is this a bug or a feature?
If I store a static value 'world' for bar in config.json, but want to
override it for this one-time execution on the command line, with --bar
moon, I expect to see moon, not world.
I only expect to see world if I don't specify any option, which means the
value of bar should be its *default* one, read from the config.json file.
Do I interpret that incorrectly?
Should I expect to override on command-line, with options, a *default*
value read from a configuration file?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#25?email_source=notifications&email_token=AAE2X462JP6JVMJZ5PDUUPDQQ2LDBA5CNFSM4JFWUZ4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HUWAZ5Q>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE2X46E77W7SK4XG5DTKTDQQ2LDBANCNFSM4JFWUZ4A>
.
|
@jpillora OK, I thought I was using opts incorrectly ;-) I'll have a look at the code then. In the meantime, I found the "workaround" of:
Not very convenient, but it works. |
VonC
added a commit
to VonC/opts
that referenced
this issue
Oct 28, 2019
A command-line parameter ought to override a default value from a JSON configuration file. See issue jpillora#25
VonC
added a commit
to VonC/opts
that referenced
this issue
Mar 12, 2022
A command-line parameter ought to override a default value from a JSON configuration file. See issue jpillora#25
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The "Features with examples" sections includes:
It refers to eg-config, which shows the program returns the config file default value, even when the command-line option specifies a different value.
Is this a bug or a feature?
If I store a static value '
world
' forbar
in config.json, but want to override it for this one-time execution on the command line, with--bar moon
, I expect to seemoon
, notworld
.I only expect to see
world
if I don't specify any option, which means the value ofbar
should be its default one, read from theconfig.json
file.Do I interpret that incorrectly?
Should I expect to override on command-line, with options, a default value read from a configuration file?
The text was updated successfully, but these errors were encountered: