Redirect brew cask search
to brew search
.
This commit is contained in:
parent
da193d2f7e
commit
8c620d8b97
@ -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"
|
||||
|
@ -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}”?"
|
||||
|
@ -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
|
@ -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"
|
||||
|
@ -1,4 +1,4 @@
|
||||
require "cask/lib/hbc/cli/options"
|
||||
require "hbc/cli/options"
|
||||
|
||||
module Hbc
|
||||
class CLI
|
||||
|
21
Library/Homebrew/compat/hbc/cli/search.rb
Normal file
21
Library/Homebrew/compat/hbc/cli/search.rb
Normal 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
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user