diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 455918b1d1..4077d7f3ee 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -78,9 +78,12 @@ module Homebrew if args.json raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "This command's option requires a formula argument" if ARGV.named.empty? print_json elsif args.github? + raise UsageError, "This command's option requires a formula argument" if ARGV.named.empty? + exec_browser(*Homebrew.args.formulae.map { |f| github_info(f) }) else print_info diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb index f22f8f6289..fd20bec0fb 100644 --- a/Library/Homebrew/cmd/postinstall.rb +++ b/Library/Homebrew/cmd/postinstall.rb @@ -23,6 +23,8 @@ module Homebrew def postinstall postinstall_args.parse + raise KegUnspecifiedError if args.remaining.empty? + ARGV.resolved_formulae.each do |f| ohai "Postinstalling #{f}" fi = FormulaInstaller.new(f) diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 126cb7242a..67acf71b4d 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -47,6 +47,8 @@ module Homebrew def reinstall reinstall_args.parse + raise FormulaUnspecifiedError if args.remaining.empty? + FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed? Install.perform_preinstall_checks diff --git a/Library/Homebrew/cmd/switch.rb b/Library/Homebrew/cmd/switch.rb index c7e3a1850a..154ddba4e3 100644 --- a/Library/Homebrew/cmd/switch.rb +++ b/Library/Homebrew/cmd/switch.rb @@ -14,46 +14,32 @@ module Homebrew Symlink all of the specified of 's installation into Homebrew's prefix. EOS - switch_option :verbose - switch_option :debug + switch :verbose + switch :debug end end def switch switch_args.parse + + raise FormulaUnspecifiedError if args.remaining.empty? + name = args.remaining.first - - usage = "Usage: brew switch " - - unless name - onoe usage - exit 1 - end - rack = Formulary.to_rack(name) - unless rack.directory? - onoe "#{name} not found in the Cellar." - exit 2 - end + odie "#{name} not found in the Cellar." unless rack.directory? versions = rack.subdirs .map { |d| Keg.new(d).version } .sort .join(", ") version = args.remaining.second + raise UsageError, "Specify one of #{name}'s installed versions: #{versions}" unless version - if !version || args.remaining.length > 2 - onoe usage - puts "#{name} installed versions: #{versions}" - exit 1 - end - - unless (rack/version).directory? - onoe "#{name} does not have a version \"#{version}\" in the Cellar." - puts "#{name} installed versions: #{versions}" - exit 3 - end + odie <<~EOS unless (rack/version).directory? + #{name} does not have a version \"#{version}\" in the Cellar. + #{name}'s installed versions: #{versions} + EOS # Unlink all existing versions rack.subdirs.each do |v| diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 97fe7bfa84..25d073e8a8 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -86,6 +86,7 @@ module Homebrew bottle_args.parse return merge if args.merge? + raise KegUnspecifiedError if args.remaining.empty? ensure_relocation_formulae_installed! unless args.skip_relocation? ARGV.resolved_formulae.each do |f| @@ -426,6 +427,7 @@ module Homebrew def merge write = args.write? + raise UsageError, "--merge requires a JSON file path argument" if ARGV.named.empty? bottles_hash = ARGV.named.reduce({}) do |hash, json_file| hash.deep_merge(JSON.parse(IO.read(json_file)))