diff --git a/Library/Homebrew/cmd/analytics.rb b/Library/Homebrew/cmd/analytics.rb index 17e225cec4..99d20650ae 100644 --- a/Library/Homebrew/cmd/analytics.rb +++ b/Library/Homebrew/cmd/analytics.rb @@ -42,7 +42,7 @@ module Homebrew when "regenerate-uuid" Utils::Analytics.regenerate_uuid! else - raise UsageError + raise UsageError, "Unknown subcommand." end end end diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb index 291690ebe5..b866ec280d 100644 --- a/Library/Homebrew/cmd/command.rb +++ b/Library/Homebrew/cmd/command.rb @@ -20,12 +20,11 @@ module Homebrew def command command_args.parse - abort "This command requires a command argument" if args.remaining.empty? + + raise UsageError, "This command requires a command argument" if args.remaining.empty? cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(args.remaining.first, args.remaining.first) - path = Commands.path(cmd) - cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) unless path path ||= which("brew-#{cmd}", cmd_paths) path ||= which("brew-#{cmd}.rb", cmd_paths) diff --git a/Library/Homebrew/cmd/diy.rb b/Library/Homebrew/cmd/diy.rb index 70f8e63668..42862422d1 100644 --- a/Library/Homebrew/cmd/diy.rb +++ b/Library/Homebrew/cmd/diy.rb @@ -47,7 +47,6 @@ module Homebrew def detect_version(path) version = path.version.to_s - raise "Couldn't determine version, set it with --version=" if version.empty? version diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 94a82c68b0..455918b1d1 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -61,22 +61,23 @@ module Homebrew def info info_args.parse + if args.days.present? - raise UsageError, "days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days) + raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days) end if args.category.present? if ARGV.named.present? && !VALID_FORMULA_CATEGORIES.include?(args.category) - raise UsageError, "category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae" + raise UsageError, "--category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae" end unless VALID_CATEGORIES.include?(args.category) - raise UsageError, "category must be one of #{VALID_CATEGORIES.join(", ")}" + raise UsageError, "--category must be one of #{VALID_CATEGORIES.join(", ")}" end end if args.json - raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json print_json elsif args.github? diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index a3c428c754..44fb8bd961 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -101,6 +101,7 @@ module Homebrew end install_args.parse + raise FormulaUnspecifiedError if args.remaining.empty? if args.ignore_dependencies? diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb index 1697be6a6e..28e29331f4 100644 --- a/Library/Homebrew/cmd/link.rb +++ b/Library/Homebrew/cmd/link.rb @@ -48,7 +48,10 @@ module Homebrew else keg.name end - puts "To relink: brew unlink #{keg.name} && brew link #{name_and_flag}" + puts <<~EOS + To relink: + brew unlink #{keg.name} && brew link #{name_and_flag} + EOS next end diff --git a/Library/Homebrew/cmd/missing.rb b/Library/Homebrew/cmd/missing.rb index e89fac4c58..c8e41387f7 100644 --- a/Library/Homebrew/cmd/missing.rb +++ b/Library/Homebrew/cmd/missing.rb @@ -27,6 +27,7 @@ module Homebrew def missing missing_args.parse + return unless HOMEBREW_CELLAR.exist? ff = if ARGV.named.empty? diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb index b329557c47..c6161d8707 100644 --- a/Library/Homebrew/cmd/outdated.rb +++ b/Library/Homebrew/cmd/outdated.rb @@ -41,7 +41,7 @@ module Homebrew ARGV.resolved_formulae end if args.json - raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json outdated = print_outdated_json(formulae) else diff --git a/Library/Homebrew/cmd/sh.rb b/Library/Homebrew/cmd/sh.rb index 3a082c86cc..25e866b628 100644 --- a/Library/Homebrew/cmd/sh.rb +++ b/Library/Homebrew/cmd/sh.rb @@ -27,6 +27,7 @@ module Homebrew def sh sh_args.parse + ENV.activate_extensions! if superenv? diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb index 1b0d9a212d..73ff8097d4 100644 --- a/Library/Homebrew/cmd/tap-info.rb +++ b/Library/Homebrew/cmd/tap-info.rb @@ -36,7 +36,7 @@ module Homebrew end if args.json - raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json print_tap_json(taps.sort_by(&:to_s)) else diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index a508f94d92..0f4900069f 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -79,7 +79,7 @@ module Homebrew if rack.directory? versions = rack.subdirs.map(&:basename) puts "#{keg.name} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed." - puts "Remove all versions with `brew uninstall --force #{keg.name}`." + puts "Run `brew uninstall --force #{keg.name}` to remove all versions." end end end @@ -87,7 +87,7 @@ module Homebrew end rescue MultipleVersionsInstalledError => e ofail e - puts "Use `brew uninstall --force #{e.name}` to remove all versions." + puts "Run `brew uninstall --force #{e.name}` to remove all versions." ensure # If we delete Cellar/newname, then Cellar/oldname symlink # can become broken and we have to remove it. diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb index 96ce316d1d..5dd45a2bc1 100644 --- a/Library/Homebrew/cmd/untap.rb +++ b/Library/Homebrew/cmd/untap.rb @@ -19,11 +19,11 @@ module Homebrew def untap untap_args.parse - raise "Usage is `brew untap `" if args.remaining.empty? + raise UsageError, "This command requires a tap argument from `brew tap`'s list" if args.remaining.empty? ARGV.named.each do |tapname| tap = Tap.fetch(tapname) - raise "untapping #{tap} is not allowed" if tap.core_tap? + odie "Untapping #{tap} is not allowed" if tap.core_tap? tap.uninstall end diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 483f770080..745ff6372b 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -314,7 +314,7 @@ homebrew-update() { *) odie <>"$update_failed_file" + echo "$TAP does not exist! Run \`brew untap $TAP\` to remove it." >>"$update_failed_file" else echo "Fetching $DIR failed!" >>"$update_failed_file" fi diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 8f1f8c81f5..97fe7bfa84 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -219,7 +219,7 @@ module Homebrew return end - return ofail "Formula not installed with '--build-bottle': #{f.full_name}" unless Utils::Bottles.built_as? f + return ofail "Formula was not installed with --build-bottle: #{f.full_name}" unless Utils::Bottles.built_as? f return ofail "Formula has no stable version: #{f.full_name}" unless f.stable diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index e984152e78..d53c8532b0 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -504,6 +504,6 @@ module Homebrew formula.path.atomic_write(backup_file) FileUtils.mv alias_rename.last, alias_rename.first if alias_rename.present? - odie "brew audit failed!" + odie "`brew audit` failed!" end end diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index a5a8443cd9..3130a8f30b 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -98,7 +98,7 @@ module Homebrew extract_args.parse # Expect exactly two named arguments: formula and tap - raise UsageError if args.remaining.length != 2 + raise UsageError, "This command requires formula and tap arguments" if args.remaining.length != 2 if args.remaining.first !~ HOMEBREW_TAP_FORMULA_REGEX name = args.remaining.first.downcase diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb index 464d96b5b1..d042367d4b 100644 --- a/Library/Homebrew/dev-cmd/mirror.rb +++ b/Library/Homebrew/dev-cmd/mirror.rb @@ -21,7 +21,7 @@ module Homebrew def mirror mirror_args.parse - odie "This command requires at least one formula argument!" if ARGV.named.empty? + raise FormulaUnspecifiedError if args.remaining.empty? bintray_user = ENV["HOMEBREW_BINTRAY_USER"] bintray_key = ENV["HOMEBREW_BINTRAY_KEY"] diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 2233659189..93505328e5 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -70,7 +70,9 @@ module Homebrew pull_args.parse - odie "This command requires at least one argument containing a URL or pull request number" if ARGV.named.empty? + if ARGV.named.empty? + raise UsageError, "This command requires at least one argument containing a URL or pull request number" + end # Passthrough Git environment variables for e.g. git am ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"] if ENV["HOMEBREW_GIT_NAME"] @@ -107,7 +109,7 @@ module Homebrew end _, testing_job = *testing_match url = "https://github.com/Homebrew/homebrew-#{tap.repo}/compare/master...BrewTestBot:testing-#{testing_job}" - odie "Testing URLs require `--bottle`!" unless args.bottle? + odie "--bottle is required for testing job URLs!" unless args.bottle? elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX) _, user, repo, issue = *api_match url = "https://github.com/#{user}/#{repo}/pull/#{issue}" @@ -277,7 +279,7 @@ module Homebrew elsif patch_changes[:formulae].length > 1 odie "Can only bump one changed formula; bumped #{patch_changes[:formulae]}" elsif !patch_changes[:others].empty? - odie "Can not bump if non-formula files are changed" + odie "Cannot bump if non-formula files are changed" end end diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb index 23d4a9fe64..326830d793 100644 --- a/Library/Homebrew/dev-cmd/tap-new.rb +++ b/Library/Homebrew/dev-cmd/tap-new.rb @@ -21,7 +21,7 @@ module Homebrew def tap_new tap_new_args.parse - raise "A tap argument is required" if ARGV.named.empty? + raise UsageError, "This command requires a tap argument" if ARGV.named.empty? tap = Tap.fetch(ARGV.named.first) titleized_user = tap.user.dup diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb index 8f1acd3b4d..6327c6d0bf 100644 --- a/Library/Homebrew/dev-cmd/update-test.rb +++ b/Library/Homebrew/dev-cmd/update-test.rb @@ -88,7 +88,7 @@ module Homebrew chdir "update-test" do curdir = Pathname.new(Dir.pwd) - oh1 "Setup test environment..." + oh1 "Preparing test environment..." # copy Homebrew installation safe_system "git", "clone", "#{HOMEBREW_REPOSITORY}/.git", ".", "--branch", "master", "--single-branch"