support `brew cask edit`

This commit is contained in:
phinze 2012-09-21 23:32:19 -05:00
parent 029bd855db
commit b45974c224
3 changed files with 24 additions and 0 deletions

View File

@ -8,10 +8,12 @@ HOME_APPS = Pathname.new(File.expand_path("~/Applications"))
class Cask; end
require 'cask/cli'
require 'cask/cli/edit'
require 'cask/cli/install'
require 'cask/cli/linkapps'
require 'cask/cli/list'
require 'cask/cli/search'
require 'cask/exceptions'
require 'plist/parser'
class Cask

12
lib/cask/cli/edit.rb Normal file
View File

@ -0,0 +1,12 @@
class Cask::CLI::Edit
def self.run(*arguments)
cask_name, *rest = *arguments
cask_path = Cask.path.join("#{cask_name}.rb")
raise CaskUnavailableError, cask_path.basename('.rb').to_s unless cask_path.file?
exec_editor cask_path
end
def self.help
"edits the cask of the given name"
end
end

10
lib/cask/exceptions.rb Normal file
View File

@ -0,0 +1,10 @@
class CaskUnavailableError < RuntimeError
attr_reader :name
def initialize name
@name = name
end
def to_s
"No available cask for #{name}"
end
end