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

Configuration loading improvements (fixes #79) #81

Merged
merged 1 commit into from
Jul 10, 2019

Conversation

tony-iqlusion
Copy link
Member

  • 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.

@@ -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)?))
Copy link
Contributor

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)?

Copy link
Collaborator

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

Copy link
Contributor

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).

Copy link
Collaborator

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.
@tony-iqlusion tony-iqlusion changed the title [WIP] Configuration loading improvements (fixes #79) Configuration loading improvements (fixes #79) Jul 9, 2019
@tony-iqlusion
Copy link
Member Author

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.

@tony-iqlusion tony-iqlusion merged commit e93295f into develop Jul 10, 2019
@tony-iqlusion tony-iqlusion deleted the config-fixups branch July 10, 2019 01:32
@tony-iqlusion tony-iqlusion mentioned this pull request Jul 17, 2019
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.

None yet

3 participants