You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default value is not respected when parsing an empty argument e.g. /my/binwithout the --foo bar will not produce Config{Foo: "bar"}. I think it would be nicer if this package would set the default value of bar when the flag is not present in the args. What do you think?
If there is interest in implementing this, I already have a draft PR ready which I wrote for my own personal use. I'd be happy to upstream it here.
The text was updated successfully, but these errors were encountered:
Thanks William
I considered a default field in the struct tag a while back and went with
leaving it out - in favour of initialising the struct passed to opts.New
I think we could still add it now, but what should we do when the two
defaults are both defined?
We could add rules about which default to use though IMO, this adds a
confusion when using opts which I’d like to avoid
Another alternative is to panic, which keeps it simple and clear - however,
there is a slight chance that this breaks existing programs - though I
still prefer the panic over the rules
Is there a situation you found where you couldn’t initialise the struct?
On Wed, 26 Jul 2023 at 4:50 am William Findlay ***@***.***> wrote:
I went ahead and filed the PR I discussed above. Feel free to close it if
this is not something you want to implement.
—
Reply to this email directly, view it on GitHub
<#36 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE2X4ZTO5YZR4Z2GUJ6QGTXSAIORANCNFSM6AAAAAA2XO5Y5M>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
I noticed that when defining something like the following:
The default value is not respected when parsing an empty argument e.g.
/my/bin
without the--foo bar
will not produceConfig{Foo: "bar"}
. I think it would be nicer if this package would set the default value ofbar
when the flag is not present in the args. What do you think?If there is interest in implementing this, I already have a draft PR ready which I wrote for my own personal use. I'd be happy to upstream it here.
The text was updated successfully, but these errors were encountered: