reinstall: Use CLI::Parser to parse args
This commit is contained in:
parent
fd8206567b
commit
2736aed1fd
@ -11,11 +11,30 @@ require "formula_installer"
|
|||||||
require "development_tools"
|
require "development_tools"
|
||||||
require "messages"
|
require "messages"
|
||||||
require "reinstall"
|
require "reinstall"
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
def reinstall_args
|
||||||
|
Homebrew::CLI::Parser.new do
|
||||||
|
usage_banner <<~EOS
|
||||||
|
`reinstall` [<option(s)>] <formula>:
|
||||||
|
|
||||||
|
Uninstall and then install <formula> (with existing install options).
|
||||||
|
|
||||||
|
If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions
|
||||||
|
of upgraded <formulae> as well as the HOMEBREW_CACHE for that formula.
|
||||||
|
EOS
|
||||||
|
switch "--display-times",
|
||||||
|
description: "Print install times for each formula at the end of the run."
|
||||||
|
switch :debug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def reinstall
|
def reinstall
|
||||||
|
reinstall_args.parse
|
||||||
|
|
||||||
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?
|
||||||
|
|
||||||
Install.perform_preinstall_checks
|
Install.perform_preinstall_checks
|
||||||
|
|||||||
@ -22,9 +22,8 @@ describe "brew reinstall", :integration_test do
|
|||||||
|
|
||||||
it "reinstalls a Formula even when one of the options is invalid" do
|
it "reinstalls a Formula even when one of the options is invalid" do
|
||||||
expect { brew "reinstall", "testball", "--with-fo" }
|
expect { brew "reinstall", "testball", "--with-fo" }
|
||||||
.to output(/Reinstalling testball --with-foo/).to_stdout
|
.to output(/Error: invalid option: --with-fo/).to_stderr
|
||||||
.and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr
|
.and be_a_failure
|
||||||
.and be_a_success
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "refuses to reinstall a pinned Formula, but doesn't fail" do
|
it "refuses to reinstall a pinned Formula, but doesn't fail" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user