-
Notifications
You must be signed in to change notification settings - Fork 38
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
Configuration loading improvements (fixes #79) #81
Conversation
@@ -100,7 +100,7 @@ pub trait Application: Default + Sized { | |||
// Load configuration | |||
let config = command | |||
.config_path() | |||
.map(|_| self.load_config(command)) | |||
.map(|path| command.process_config(self.load_config(&path)?)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if load_config
fails? Does the error bubble up to exit the program, or does it just not load the config (cf. #80)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It bubbles up here, and the application exits:
https://github.com/iqlusioninc/abscissa/blob/develop/src/application.rs#L58
If you'd like for a nonexistent config file to be ignored, the command's config_path()
needs to check for the file's existence in advance, and if it's not there, return None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm confused because I thought from #80 (comment) that the intent was that config_path
doesn't need to check. (Either way is fine, as long as it's clear one way or the other).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't need to check if you're fine with the application exiting with an error if the config doesn't exist.
If you want an absent config to be ignored, config_path()
needs to return None
- Have `command::EntryPoint` delegate its `Configurable` impl to the command it wraps. - Simplify configuration loading logic in `Application`. - Rename `config::MergeOptions` to `config::Override` and provide an example of how to use it in the boilerplate.
Removed WIP. I planned on trying to get a bit more into this commit to actually exercise and test the changes, but I think I'll do that in a followup which improves the configuration testing story. |
command::EntryPoint
delegate itsConfigurable
impl to the command it wraps.Application
.config::MergeOptions
toconfig::Override
and provide an example of how to use it in the boilerplate.