-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Autodetect config format based on extension #1702
Autodetect config format based on extension #1702
Conversation
Should add .yml aswell for yaml |
a5572f6
to
6de748e
Compare
6de748e
to
2f85d54
Compare
Done! |
Now to add the new tests. |
bd44aba
to
2588179
Compare
2588179
to
1d1e48a
Compare
Ahh circular dependencies... Moving the InputSourceContext interface to cli is a backwards compatibility issue. I'm not sure how used it is, maybe someone else can provide some insight. @urfave/cli I put some time into it, and I'm not sure how it could be done differently. Maybe you have other ideas if the compatibility is an issue @danhunsaker |
151e8b4
to
1d1e48a
Compare
If Go offered a way to attach objects to other objects without defining an explicit name first... Though maybe we could add something more generic for myriad extensions to use... 🤔 |
6c2c5ed
to
4439bfa
Compare
@danhunsaker v2 is only in maintenance mode right now. No new features/capabilities. Can you do this PR for v3/main ? |
- Move things back to `altsrc` - Add support for extensions to `App` - Implement `DetectableSourcesAppExtension` to hold `detectableSources` - Refactor code and tests for the revised setup, including making the extension only needed for adding additional handlers
4439bfa
to
3c3d505
Compare
Sure, once v3 is actually out of alpha and into a real release. I can't use/test it until then. Also, I don't see support for |
v3 is the mainline branch. Alpha will be out soon. altsrc has been moved into its own repo for v3 since it is ancillary to cli and not a core. |
There's nothing anywhere pointing it out, so I didn't know there was a separate repository. I'll see what I can do with that. |
@danhunsaker Thanks for your patience! The transitional state of the |
Closing as per the comments above. v2 is in maintenance mode and we don't accept new features for it. Thank you for the contribution, and if possible, please submit it to https://github.com/urfave/cli-altsrc |
What type of PR is this?
What this PR does / why we need it:
DetectNewSourceFromFlagFunc(flag)
to support configs in more than one format for a single application, by autodetecting which format to parse with according to the config file's extension.New*SourceFromFlagFunc()
functions to new file extensions for support by the autodetector..yaml
→NewYamlSourceFromFlagFunc
.yml
→NewYamlSourceFromFlagFunc
.json
→NewJSONSourceFromFlagFunc
.toml
→NewTomlSourceFromFlagFunc
.conf
→NewTomlSourceFromFlagFunc
Testing
main.go
config.yaml
config.json
config.toml
config.conf
config.yml
Release Notes