Redirect brew cask search to brew search.

This commit is contained in:
Markus Reiter 2018-06-09 15:40:44 +02:00
parent da193d2f7e
commit 8c620d8b97
8 changed files with 29 additions and 58 deletions

View File

@ -21,7 +21,6 @@ require "hbc/cli/install"
require "hbc/cli/list"
require "hbc/cli/outdated"
require "hbc/cli/reinstall"
require "hbc/cli/search"
require "hbc/cli/style"
require "hbc/cli/uninstall"
require "hbc/cli/upgrade"

View File

@ -1,9 +1,11 @@
require_relative "options"
require "search"
module Hbc
class CLI
class AbstractCommand
include Options
include Homebrew::Search
option "--[no-]binaries", :binaries, true
option "--debug", :debug, false
@ -50,7 +52,7 @@ module Hbc
end
def suggestion_message(cask_token)
matches, = Search.search(cask_token)
matches = search_casks(cask_token)
if matches.one?
"Did you mean “#{matches.first}”?"

View File

@ -1,53 +0,0 @@
require "search"
module Hbc
class CLI
class Search < AbstractCommand
extend Homebrew::Search
def run
if args.empty?
puts Formatter.columns(CLI.nice_listing(Cask.map(&:qualified_token)))
else
results = self.class.search(*args)
self.class.render_results(*results)
end
end
def self.search(*arguments)
query = arguments.join(" ")
string_or_regex = query_regexp(query)
local_results = search_casks(string_or_regex)
remote_matches = search_taps(query, silent: true)[:casks]
[local_results, remote_matches, query]
end
def self.render_results(partial_matches, remote_matches, search_term)
unless $stdout.tty?
puts [*partial_matches, *remote_matches]
return
end
if partial_matches.empty? && remote_matches.empty?
puts "No Cask found for \"#{search_term}\"."
return
end
unless partial_matches.empty?
ohai "Matches"
puts Formatter.columns(partial_matches)
end
return if remote_matches.empty?
ohai "Remote Matches"
puts Formatter.columns(remote_matches)
end
def self.help
"searches all known Casks"
end
end
end
end

View File

@ -1,4 +1,5 @@
require "compat/hbc/cask_loader"
require "compat/hbc/cli/search"
require "compat/hbc/cli/update"
require "compat/hbc/cache"
require "compat/hbc/caskroom"

View File

@ -1,4 +1,4 @@
require "cask/lib/hbc/cli/options"
require "hbc/cli/options"
module Hbc
class CLI

View File

@ -0,0 +1,21 @@
require "hbc/cli/abstract_command"
require "cmd/search"
module Hbc
class CLI
module Compat
class Search < AbstractCommand
def run
odeprecated "`brew cask search`", "`brew search`"
Homebrew.search(args)
end
def self.visible
false
end
end
end
prepend Compat
end
end

View File

@ -1,10 +1,10 @@
require "cask/lib/hbc/cli/abstract_command"
require "hbc/cli/abstract_command"
module Hbc
class CLI
module Compat
class Update < AbstractCommand
def self.run(*_ignored)
def run
odisabled "`brew cask update`", "`brew update`"
end

View File

@ -16,6 +16,7 @@ require "time"
def require?(path)
return false if path.nil?
require path
true
rescue LoadError => e
# we should raise on syntax errors but not if the file doesn't exist.
raise unless e.message.include?(path)