28 lines
699 B
Ruby
Raw Normal View History

2016-09-24 13:52:43 +02:00
module Hbc
class CLI
2017-05-20 19:08:03 +02:00
class Edit < AbstractCommand
2017-05-21 00:15:56 +02:00
def initialize(*)
super
raise CaskUnspecifiedError if args.empty?
raise ArgumentError, "Only one Cask can be created at a time." if args.count > 1
end
2017-05-19 22:01:50 +02:00
def run
2017-05-21 00:15:56 +02:00
cask_token = args.first
cask_path = CaskLoader.path(cask_token)
2017-05-21 00:15:56 +02:00
2016-09-24 13:52:43 +02:00
unless cask_path.exist?
2017-06-11 02:00:59 +02:00
raise CaskUnavailableError.new(cask_token, "Run #{Formatter.identifier("brew cask create #{cask_token}")} to create a new Cask.")
2016-09-24 13:52:43 +02:00
end
2017-05-21 00:15:56 +02:00
odebug "Opening editor for Cask #{cask_token}"
2016-09-24 13:52:43 +02:00
exec_editor cask_path
end
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
def self.help
"edits the given Cask"
end
end
2016-08-18 22:11:42 +03:00
end
end