diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 6bd1f41f88..8324276de9 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -11,11 +11,30 @@ require "formula_installer" require "development_tools" require "messages" require "reinstall" +require "cli_parser" module Homebrew module_function + def reinstall_args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `reinstall` [] : + + Uninstall and then install (with existing install options). + + If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions + of upgraded 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 + reinstall_args.parse + FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed? Install.perform_preinstall_checks diff --git a/Library/Homebrew/test/cmd/reinstall_spec.rb b/Library/Homebrew/test/cmd/reinstall_spec.rb index 317199fb0d..ab64d5e0cf 100644 --- a/Library/Homebrew/test/cmd/reinstall_spec.rb +++ b/Library/Homebrew/test/cmd/reinstall_spec.rb @@ -22,9 +22,8 @@ describe "brew reinstall", :integration_test do it "reinstalls a Formula even when one of the options is invalid" do expect { brew "reinstall", "testball", "--with-fo" } - .to output(/Reinstalling testball --with-foo/).to_stdout - .and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr - .and be_a_success + .to output(/Error: invalid option: --with-fo/).to_stderr + .and be_a_failure end it "refuses to reinstall a pinned Formula, but doesn't fail" do