Skip to content
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

Set default flag when default tag is set and no value present #36

Open
willfindlay opened this issue Jul 25, 2023 · 2 comments · May be fixed by #37
Open

Set default flag when default tag is set and no value present #36

willfindlay opened this issue Jul 25, 2023 · 2 comments · May be fixed by #37

Comments

@willfindlay
Copy link

I noticed that when defining something like the following:

	type Config struct {
		Foo string `opts:"default=bar"`
	}

The default value is not respected when parsing an empty argument e.g. /my/bin without 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.

@willfindlay willfindlay linked a pull request Jul 25, 2023 that will close this issue
@willfindlay
Copy link
Author

I went ahead and filed the PR I discussed above. Feel free to close it if this is not something you want to implement.

@jpillora
Copy link
Owner

jpillora commented Jul 26, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants