reinstall: Use CLI::Parser to parse args

This commit is contained in:
Gautham Goli 2018-11-07 22:17:36 +05:30
parent fd8206567b
commit 2736aed1fd
No known key found for this signature in database
GPG Key ID: 6A9ABBC284468364
2 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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