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

Config file loading could be better #14

Open
kornypoet opened this issue Oct 28, 2011 · 0 comments
Open

Config file loading could be better #14

kornypoet opened this issue Oct 28, 2011 · 0 comments

Comments

@kornypoet
Copy link
Contributor

First, and foremost: When configliere loads a file, it does not decorate the hash with dotted accessors. This seems like an oversight and results in unexpected behavior.

Currently, you load configuration files like this:

Settings.read("/path/to/my/config")

What if I wanted to pass the config file as a command line argument to be read in?

./my_script.rb /path/to/my/config

This needs to be interpreted in the file by my own logic then:

Settings.use :commandline
Settings.resolve!
Settings.read(Settings.rest.first) # Settings.rest give you the the command line args (ARGV) passed in

This is more difficult to express than it should be. We could try including it as a param, but this is just as gross:

./my_script.rb --config_file=/path/to/my/config

And then in my script:

Settings.define :config_file
Settings.read(Settings.config_file)
Settings.resolve!

At least with this, the config is read in before the command line arguments are resolved, allowing for overrides.

I propose a special flag (--read_config=?) that is interpreted as "load this file by default", then proceed with other definitions, and params. This allows for command line overriding, while abstracting out a pattern that is needlessly verbose, and keeps everything conceptually related.

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

No branches or pull requests

1 participant