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
Add initconfig support for command defaults, allow strings as config keys #257
base: gli-2
Are you sure you want to change the base?
Add initconfig support for command defaults, allow strings as config keys #257
Conversation
@@ -0,0 +1,17 @@ | |||
# adapted from https://gist.github.com/Integralist/9503099 | |||
class Object |
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.
Can we not monkeypatch core classes? This is likely going to break anyone that uses GLI with Rails/ActiveSupport.
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.
Looking over the rest of the PR, I think a better way to do this is make a class whose job is to load the configuration and have it do all this string/symbol copying, so we don't infect every object in the entire system with a method that's only needed in a couple of places.
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.
Yes, that's fair. It hadn't occurred to me that a GLI project might also have ActiveSupport loaded.
Thanks for doing this! Other than the issues with monkeypatching, the overall change looks great! |
Got rid of the monkeypatching, which I admit was reckless. |
|
||
# adapted from https://gist.github.com/Integralist/9503099 | ||
def self.apply_indifferent_access_to(obj) | ||
return obj.reduce({}) do |memo, (k, v)| |
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.
Sorry to nitpick, but can you use a more traditional if
construct? Trailing if
s for multiple lines is really confusing to me.
Thanks and sorry for the delay in looking at this. Just one tiny nitpick, but otherwise this looks good. Thanks! |
Fixes #63
The
initconfig
command will now write out all of the switches and flags for any commands and any subcommands. It writes config keys as strings, though symbols will still work.