-
Notifications
You must be signed in to change notification settings - Fork 91
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
Using persistent config file for execution #174
base: master
Are you sure you want to change the base?
Conversation
1f65e32
to
2c94561
Compare
- storing default execution configuration in user home - adding option to ignore changes made to user config - updating README - fixing rubocop offenses
2c94561
to
83a4f9e
Compare
Please do not put configuration dotfiles directly into user home dir. XDG Base Dir Spec is more than a decade old, majority of cli apps use it, like Configuration files should be placed into |
default_options.quiet = default_values["quiet"] | ||
default_options.verbose = default_values["verbose"] | ||
default_options.interactive = default_values["interactive"] | ||
default_options.debug = default_values["debug"] |
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.
the value debug
is not in default_values
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.
should a loop over the hash and a default_options[option_name] = default_values[option_name]
a little shorter and include all options from hash?
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.
i see there you also can write when you don't need to exclude some keys:
default_options = OpenStruct.new(default_values)
unless File.exist?(config_filename) | ||
odebug "Config file doesn't exist, creating" | ||
create_default_config_file config_filename | ||
end |
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.
I don't expect here as an user that a normal brew cu
creates always the config file.
if there is no config then do not create one.
only if there is an command brew cu --create-config
I would expect that a config will be created.
my suggestion: remove this part and create an new command - or leave the creation of this to the user.
options = (YAML.safe_load f.read).to_h | ||
odebug "Configuration loaded", options | ||
end | ||
OpenStruct.new options |
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.
-
at this point i would filter the keys to only allow keys which are known
-
maybe show an error message when keys are unknown - for example if there is a typo
|
||
default_options = create_default_options | ||
if File.exist?(config_filename) | ||
odebug "Loading configuration from config file" |
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.
add config file name
Description
In order to allow changing default configuration for user execution, the default config is stored in user home directory.
Any additional options passed to the command have preference.
Closes #156
Actions taken
CC: @muescha