mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 06:16:47 -06:00
add brew cask info command
thanks to @passcod for original implementation on his fork refs #72
This commit is contained in:
parent
f866a18725
commit
ff80676b29
2 changed files with 68 additions and 0 deletions
39
lib/cask/cli/info.rb
Normal file
39
lib/cask/cli/info.rb
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
class Cask::CLI::Info
|
||||
def self.run(*cask_names)
|
||||
cask_names.each do |cask_name|
|
||||
begin
|
||||
cask = Cask.load(cask_name)
|
||||
puts info(cask)
|
||||
rescue CaskUnavailableError => e
|
||||
onoe e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.help
|
||||
"displays information about the cask of the given name"
|
||||
end
|
||||
|
||||
def self.info(cask)
|
||||
installation = if cask.installed?
|
||||
"#{cask.destination_path} (#{cask.destination_path.abv})"
|
||||
else
|
||||
"Not installed"
|
||||
end
|
||||
|
||||
<<-PURPOSE.undent
|
||||
#{cask}: #{cask.version}
|
||||
#{cask.homepage}
|
||||
#{installation}
|
||||
#{github_info(cask)}
|
||||
PURPOSE
|
||||
end
|
||||
|
||||
def self.github_info(cask)
|
||||
tap = cask.title
|
||||
tap = cask.class.all_titles.grep(/#{tap}$/).first unless tap =~ /\//
|
||||
tap, name = tap.split "/"
|
||||
user, repo = tap.split "-"
|
||||
"https://github.com/#{user}/#{repo}/commits/master/Casks/#{name}.rb"
|
||||
end
|
||||
end
|
||||
29
test/cli/info_test.rb
Normal file
29
test/cli/info_test.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require 'test_helper'
|
||||
|
||||
describe Cask::CLI::Info do
|
||||
it 'displays some nice info about the specified cask' do
|
||||
lambda {
|
||||
Cask::CLI::Info.run('alfred')
|
||||
}.must_output <<-CLIOUTPUT.undent
|
||||
alfred: 1.3.2_265
|
||||
http://www.alfredapp.com/
|
||||
Not installed
|
||||
https://github.com/phinze/cask/commits/master/Casks/alfred.rb
|
||||
CLIOUTPUT
|
||||
end
|
||||
|
||||
it 'works for multiple casks' do
|
||||
lambda {
|
||||
Cask::CLI::Info.run('alfred', 'firefox')
|
||||
}.must_output <<-CLIOUTPUT.undent
|
||||
alfred: 1.3.2_265
|
||||
http://www.alfredapp.com/
|
||||
Not installed
|
||||
https://github.com/phinze/cask/commits/master/Casks/alfred.rb
|
||||
firefox: 17.0.1
|
||||
http://www.mozilla.org/en-US/firefox/
|
||||
Not installed
|
||||
https://github.com/phinze/cask/commits/master/Casks/firefox.rb
|
||||
CLIOUTPUT
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue