-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
install: Use CLI::Parser to parse args #5619
Conversation
c17cf1d
to
12eb104
Compare
Library/Homebrew/cmd/install.rb
Outdated
@@ -317,11 +397,11 @@ def install_formula(f) | |||
fi = FormulaInstaller.new(f) | |||
fi.options = build_options.used_options | |||
fi.invalid_option_names = build_options.invalid_option_names |
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.
Might be a good idea to use the build_options.invalid_option_names
above instead of the formulae loop?
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, I'm not sure I understand. Can you explain this more?
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.
Sure. This is used at
brew/Library/Homebrew/formula_installer.rb
Lines 270 to 272 in 0670282
invalid_option_names.each do |option| | |
opoo "#{formula.full_name}: this formula has no #{option} option so it will be ignored!" | |
end |
build_options.invalid_option_names
already exists perhaps that method could be used instead, used for inspiration (or deleted): brew/Library/Homebrew/build_options.rb
Lines 102 to 116 in 0670282
# @private | |
def invalid_options | |
@args - @options - BuildOptions.formula_install_options | |
end | |
# @private | |
def invalid_option_names | |
invalid_options.map(&:flag).sort | |
end | |
def self.formula_install_options | |
@formula_install_options ||= ARGV.formula_install_option_names.map do |option_name| | |
Option.new option_name[2..-1] | |
end | |
end |
Make sense?
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.
Thanks @MikeMcQuaid. Got it.
One more question.
In the existing behaviour, we ignore the invalid options passed, but that is not possible with OptionParser
, as we only declare the valid options. Do we ideally want to preserve this functionality?
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.
@GauthamGoli If we're only looking at externally passed options I think it's fine/better to error out rather than ignoring and messaging 👍
Would be good to use/replace this logic: brew/Library/Homebrew/formula_installer.rb Lines 270 to 272 in 0670282
|
12eb104
to
b40579f
Compare
This is handled by `OptionParser` now instead in `cmd/install`.
e02a04d
to
49d3849
Compare
brew style
with your changes locally?brew tests
with your changes locally?#1860