Skip to content
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

reinstall: Use CLI::Parser to parse args #5274

Merged
merged 1 commit into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions Library/Homebrew/cmd/reinstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,30 @@
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` [<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
reinstall_args.parse

FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed?

Install.perform_preinstall_checks
Expand Down
5 changes: 2 additions & 3 deletions Library/Homebrew/test/cmd/reinstall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

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
Expand Down