2018-09-06 08:29:14 +02:00
|
|
|
module Cask
|
2018-09-04 08:45:48 +01:00
|
|
|
class Cmd
|
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?
|
2017-09-11 08:37:15 +02:00
|
|
|
raise ArgumentError, "Only one Cask can be edited at a time." if args.count > 1
|
2017-05-21 00:15:56 +02:00
|
|
|
end
|
|
|
|
|
2017-05-19 22:01:50 +02:00
|
|
|
def run
|
2016-09-24 13:52:43 +02:00
|
|
|
exec_editor cask_path
|
2017-09-11 08:37:15 +02:00
|
|
|
rescue CaskUnavailableError => e
|
|
|
|
reason = e.reason.empty? ? "" : "#{e.reason} "
|
|
|
|
reason.concat("Run #{Formatter.identifier("brew cask create #{e.token}")} to create a new Cask.")
|
|
|
|
raise e.class.new(e.token, reason)
|
2016-09-24 13:52:43 +02:00
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2017-10-15 22:04:20 +02:00
|
|
|
def cask_path
|
|
|
|
casks.first.sourcefile_path
|
|
|
|
rescue CaskInvalidError
|
|
|
|
path = CaskLoader.path(args.first)
|
|
|
|
return path if path.file?
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
|
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
|