2016-09-24 13:52:43 +02:00
|
|
|
module Hbc
|
|
|
|
class CLI
|
2017-05-20 19:08:03 +02:00
|
|
|
class Cat < AbstractCommand
|
2017-05-19 21:13:08 +02:00
|
|
|
def run
|
|
|
|
cask_tokens = self.class.cask_tokens_from(@args)
|
2016-09-24 13:52:43 +02:00
|
|
|
raise CaskUnspecifiedError if cask_tokens.empty?
|
|
|
|
# only respects the first argument
|
2016-10-14 20:03:34 +02:00
|
|
|
cask_token = cask_tokens.first.sub(/\.rb$/i, "")
|
2017-03-13 01:01:17 +01:00
|
|
|
cask_path = CaskLoader.path(cask_token)
|
2016-09-24 13:52:43 +02:00
|
|
|
raise CaskUnavailableError, cask_token.to_s unless cask_path.exist?
|
|
|
|
puts File.open(cask_path, &:read)
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def self.help
|
|
|
|
"dump raw source of the given Cask to the standard output"
|
|
|
|
end
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|