From 5ec396ed38ce9b48108715376c7ff38d7ad48cf9 Mon Sep 17 00:00:00 2001 From: Eric Andrew Lewis Date: Tue, 13 Oct 2015 11:56:39 -0400 Subject: [PATCH] install: make search output more intuitive. Closes Homebrew/homebrew#42222. Closes Homebrew/homebrew#44892. Signed-off-by: Mike McQuaid --- Library/Homebrew/cmd/install.rb | 32 +++++++++++++++++++++++++++++--- Library/Homebrew/exceptions.rb | 2 +- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index f7087ad8be..ac1b37b728 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -98,10 +98,36 @@ module Homebrew else ofail e.message query = query_regexp(e.name) - ohai "Searching formulae..." - puts_columns(search_formulae(query)) + + ohai "Searching for similarly named formulae..." + formulae_search_results = search_formulae(query) + case formulae_search_results.length + when 0 + ofail "No similarly named formulae found." + when 1 + puts "This similarly named formula was found:" + puts_columns(formulae_search_results) + puts "To install it, run:\n brew install #{formulae_search_results.first}" + else + puts "These similarly named formulae were found:" + puts_columns(formulae_search_results) + puts "To install one of them, run (for example):\n brew install #{formulae_search_results.first}" + end + ohai "Searching taps..." - puts_columns(search_taps(query)) + taps_search_results = search_taps(query) + case taps_search_results.length + when 0 + ofail "No formulae found in taps." + when 1 + puts "This formula was found in a tap:" + puts_columns(taps_search_results) + puts "To install it, run:\n brew install #{taps_search_results.first}" + else + puts "These formulae were found in taps:" + puts_columns(taps_search_results) + puts "To install one of them, run (for example):\n brew install #{taps_search_results.first}" + end # If they haven't updated in 48 hours (172800 seconds), that # might explain the error diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 957fc42b90..29cd480d52 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -47,7 +47,7 @@ class FormulaUnavailableError < RuntimeError end def to_s - "No available formula for #{name} #{dependent_s}" + "No available formula with the name \"#{name}\" #{dependent_s}" end end