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

Feat: Add value source #1745

Merged
merged 6 commits into from
Jun 3, 2023
Merged

Feat: Add value source #1745

merged 6 commits into from
Jun 3, 2023

Conversation

dearchap
Copy link
Contributor

What type of PR is this?

(REQUIRED)

  • feature

What this PR does / why we need it:

(REQUIRED)

This places Envs and Filepaths on same footing instead of having one take precedence over the other. In fact the user can choose which to prioritize but placing the sources in the given order. The new interface also allows plugin implementations i.e for reading values from networks, custom format files etc etc.

Which issue(s) this PR fixes:

(REQUIRED)

Special notes for your reviewer:

(fill-in or delete this section)

Testing

(fill-in or delete this section)

Updates all test case

Release Notes

(REQUIRED)


@dearchap dearchap requested a review from a team as a code owner May 30, 2023 15:13
Copy link
Contributor

@avorima avorima left a comment

Choose a reason for hiding this comment

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

It would be nice to have a convenience constructor for simple cases, e.g.

func EnvVars(...string) []FlagValueSource
func FilePaths(...string) []FlagValueSource

_ = &cli.StringFlag{
        Name: "foo",
        Sources: cli.EnvVars("FOO"),
}

There are a lot of changes in v3 and I think helpers like this would definitely make the transition easier.

flag_value_source.go Show resolved Hide resolved
flag_value_source.go Show resolved Hide resolved
flag_value_source_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@avorima avorima left a comment

Choose a reason for hiding this comment

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

👍

@dearchap dearchap merged commit 20baf49 into urfave:main Jun 3, 2023
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.

2 participants