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

Feature: Add support for multiple env #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dearchap
Copy link
Contributor

What type of PR is this?

(REQUIRED)

  • feature

What this PR does / why we need it:

(REQUIRED)

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #39

Special notes for your reviewer:

(fill-in or delete this section)

Testing

Updated existing tests

(fill-in or delete this section)

Release Notes

(REQUIRED)

Multiple env variables are supposed in tag definitions. As of now only urfave/cli supports flags with multiple envs

@dearchap dearchap requested a review from a team as a code owner November 14, 2024 02:32
@@ -27,7 +27,8 @@ func TestParseStruct(t *testing.T) {
Name4 *string
Name5 string `flag:"-"`
name6 string
Name7 int `flag:",required"`
Name7 int `flag:",required"`
Name8 float64 `flag:"name_8" env:"NAME_8,~nn_8"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~nn_8 ?

@abitrolly
Copy link
Contributor

This breaks API and I don't see how this feature is going to be used. Docs and example is needed, because it becomes not intuitive anymore. Maybe it is possible to have separate extensions for such things? To keep binary sizes and feature creep minimal?

Also, what happens for programs that use old non-array way of env specifiers.

I don't see what happens in this PR because there are no examples and docs.

@dearchap
Copy link
Contributor Author

This breaks API and I don't see how this feature is going to be used. Docs and example is needed, because it becomes not intuitive anymore. Maybe it is possible to have separate extensions for such things? To keep binary sizes and feature creep minimal?

Also, what happens for programs that use old non-array way of env specifiers.

I don't see what happens in this PR because there are no examples and docs.

Yes it breaks API but most people I am assuming use the gen cmds to translate this to a particular cli libary so they wont be affected by this. This is not a new feature I am adding. Using ~ before a name caused the parser to ignore prefix and divider options for env vars. The only thing I am doing is extending this to be a string slice instead of a string.

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 this pull request may close these issues.

New features to get to a 1.0.0 release
2 participants