Skip to content
Snippets Groups Projects
Unverified Commit 618f75c0 authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #5619 from GauthamGoli/install-args

install: Use CLI::Parser to parse args
parents d607fdfc c3ba863a
No related branches found
No related tags found
No related merge requests found
......@@ -99,22 +99,6 @@ class BuildOptions
@options - @args
end
# @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
private
def option_defined?(name)
......
......@@ -2,7 +2,7 @@
#: Upload logs for a failed build of <formula> to a new Gist.
#:
#: <formula> is usually the name of the formula to install, but it can be specified
#: in several different ways. See [SPECIFYING FORMULAE](#specifying-formulae).
#: in several different ways.
#:
#: If `--with-hostname` is passed, include the hostname in the Gist.
#:
......@@ -32,7 +32,7 @@ module Homebrew
Upload logs for a failed build of <formula> to a new Gist.
<formula> is usually the name of the formula to install, but it can be specified
in several different ways. See [SPECIFYING FORMULAE](#specifying-formulae).
in several different ways.
If no logs are found, an error message is presented.
EOS
......
This diff is collapsed.
......@@ -33,7 +33,7 @@ class FormulaInstaller
end
attr_reader :formula
attr_accessor :options, :build_bottle, :invalid_option_names
attr_accessor :options, :build_bottle
attr_accessor :installed_as_dependency, :installed_on_request, :link_keg
mode_attr_accessor :show_summary_heading, :show_header
mode_attr_accessor :build_from_source, :force_bottle, :include_test
......@@ -58,7 +58,6 @@ class FormulaInstaller
@installed_as_dependency = false
@installed_on_request = true
@options = Options.new
@invalid_option_names = []
@requirement_messages = []
@poured_bottle = false
@pour_failed = false
......@@ -267,10 +266,6 @@ class FormulaInstaller
opoo "#{formula.full_name}: #{old_flag} was deprecated; using #{new_flag} instead!"
end
invalid_option_names.each do |option|
opoo "#{formula.full_name}: this formula has no #{option} option so it will be ignored!"
end
options = display_options(formula)
if show_header?
oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip
......
......@@ -20,7 +20,6 @@ module Homebrew
fi = FormulaInstaller.new(f)
fi.options = options
fi.invalid_option_names = build_options.invalid_option_names
fi.build_bottle = ARGV.build_bottle? || (!f.bottle_defined? && f.build.bottle?)
fi.interactive = ARGV.interactive?
fi.git = ARGV.git?
......
......@@ -37,17 +37,4 @@ describe BuildOptions do
specify "#unused_options" do
expect(subject.unused_options).to include("--without-baz")
end
specify "#invalid_options" do
expect(subject.invalid_options).to be_empty
expect(bad_build.invalid_options).to include("--without-bas")
expect(bad_build.invalid_options).to include("--without-abc")
expect(bad_build.invalid_options).not_to include("--with-foo")
expect(bad_build.invalid_options).not_to include("--with-baz")
end
specify "#invalid_option_names" do
expect(subject.invalid_option_names).to be_empty
expect(bad_build.invalid_option_names).to eq(%w[--without-abc --without-bas])
end
end
......@@ -166,12 +166,12 @@ describe "brew install", :integration_test do
.and be_a_success
end
it "ignores invalid options" do
it "rejects invalid options" do
setup_test_formula "testball1"
expect { brew "install", "testball1", "--with-fo" }
.to output(/testball1: this formula has no \-\-with\-fo option so it will be ignored!/).to_stderr
.and output(/Downloading file/).to_stdout
.and be_a_success
expect { brew "install", "testball1", "--invalid" }
.to output(/Error: invalid option: --invalid/).to_stderr
.and not_to_output.to_stdout
.and be_a_failure
end
it "succeeds when a non-fatal requirement isn't satisfied" do
......
......@@ -182,7 +182,7 @@ these flags should only appear after a command.
Upload logs for a failed build of *`formula`* to a new Gist.
*`formula`* is usually the name of the formula to install, but it can be specified
in several different ways. See [SPECIFYING FORMULAE](#specifying-formulae).
in several different ways.
If `--with-hostname` is passed, include the hostname in the Gist.
......@@ -240,7 +240,7 @@ these flags should only appear after a command.
Install *`formula`*.
*`formula`* is usually the name of the formula to install, but it can be specified
in several different ways. See [SPECIFYING FORMULAE](#specifying-formulae).
in several different ways.
If `--debug` (or `-d`) is passed and brewing fails, open an interactive debugging
session with access to IRB or a shell inside the temporary build directory.
......
......@@ -184,7 +184,7 @@ If \fB\-\-force\-bottle\fR is passed, download a bottle if it exists for the cur
Upload logs for a failed build of \fIformula\fR to a new Gist\.
.
.IP
\fIformula\fR is usually the name of the formula to install, but it can be specified in several different ways\. See \fISPECIFYING FORMULAE\fR\.
\fIformula\fR is usually the name of the formula to install, but it can be specified in several different ways\.
.
.IP
If \fB\-\-with\-hostname\fR is passed, include the hostname in the Gist\.
......@@ -252,7 +252,7 @@ See the docs for examples of using the JSON output: \fIhttps://docs\.brew\.sh/Qu
Install \fIformula\fR\.
.
.IP
\fIformula\fR is usually the name of the formula to install, but it can be specified in several different ways\. See \fISPECIFYING FORMULAE\fR\.
\fIformula\fR is usually the name of the formula to install, but it can be specified in several different ways\.
.
.IP
If \fB\-\-debug\fR (or \fB\-d\fR) is passed and brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory\.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment