mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 06:16:47 -06:00
* "Canonical App Name" becomes "Simplified App Name"
* devscript `cask_namer` renamed to `generate_cask_token`
* doc file `CASK_NAMING_REFERENCE.md` renamed to `cask_token_reference.md`
* DSL uses `"#{token}"` for interpolation instead of `"#{title}"`
* documentation text
* backend code (variables, method, class names)
* error message text
* tests
* code comments
* Cask comments
* emphasize `tags :name`
* doc: use "vendor" consistently instead of "developer"
* doc: many man page argument descriptions were incorrect
* incidental clarifications
Many backend variables similar to `cask_name` or `cask` have
been standardized to `cask_token`, `token`, etc, resolving a long-
standing ambiguity in which variables named `cask` might contain
a Cask instance or a string token.
In many places the docs could be shortened from "Cask name" to
simply "token", which is desirable because we use the term "Cask"
in too many contexts.
67 lines
1.8 KiB
Ruby
67 lines
1.8 KiB
Ruby
class Cask::CLI::List < Cask::CLI::Base
|
|
def self.run(*arguments)
|
|
@options = Hash.new
|
|
@options[:one] = true if arguments.delete('-1')
|
|
@options[:long] = true if arguments.delete('-l')
|
|
|
|
if arguments.any?
|
|
retval = list_casks(*arguments)
|
|
else
|
|
retval = list_installed
|
|
end
|
|
# retval is ternary: true/false/nil
|
|
if retval.nil? and not arguments.any?
|
|
opoo "nothing to list" # special case: avoid exit code
|
|
elsif retval.nil?
|
|
raise CaskError.new("nothing to list")
|
|
elsif ! retval
|
|
raise CaskError.new("listing incomplete")
|
|
end
|
|
end
|
|
|
|
def self.list_casks(*cask_tokens)
|
|
count = 0
|
|
cask_tokens.each do |cask_token|
|
|
odebug "Listing files for Cask #{cask_token}"
|
|
cask = Cask.load(cask_token)
|
|
if cask.installed?
|
|
count += 1
|
|
list_artifacts(cask)
|
|
list_files(cask)
|
|
else
|
|
opoo "#{cask} is not installed"
|
|
end
|
|
end
|
|
count == 0 ? nil : count == cask_tokens.length
|
|
end
|
|
|
|
def self.list_artifacts(cask)
|
|
artifacts = Cask::Artifact.for_cask(cask)
|
|
artifacts.each do |artifact|
|
|
summary = artifact.new(cask).summary
|
|
ohai summary[:english_description], summary[:contents] unless summary.empty?
|
|
end
|
|
end
|
|
|
|
def self.list_files(cask)
|
|
ohai "Raw contents of Cask directory:"
|
|
Cask::PrettyListing.new(cask).print
|
|
end
|
|
|
|
def self.list_installed
|
|
installed_casks = Cask.installed
|
|
columns = installed_casks.map(&:to_s)
|
|
if @options[:one]
|
|
puts columns
|
|
elsif @options[:long]
|
|
puts Cask::SystemCommand.run!("/bin/ls", :args => ["-l", Cask.caskroom]).stdout
|
|
else
|
|
puts_columns columns
|
|
end
|
|
columns.empty? ? nil : installed_casks.length == columns.length
|
|
end
|
|
|
|
def self.help
|
|
"with no args, lists installed Casks; given installed Casks, lists staged files"
|
|
end
|
|
end
|