Class: Cask::Cmd::Edit Private

Inherits:
AbstractCommand show all
Defined in:
Library/Homebrew/cask/cmd/edit.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Implementation of the brew cask edit command.

Constant Summary

Constants inherited from AbstractCommand

AbstractCommand::OPTIONS

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractCommand

abstract?, banner_args, banner_headline, command_name, help, parser, run, short_description, visible?

Methods included from Homebrew::Search

#query_regexp, #search_casks, #search_descriptions, #search_formulae, #search_taps

Constructor Details

#initializeEdit

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Edit.


22
23
24
25
26
# File 'Library/Homebrew/cask/cmd/edit.rb', line 22

def initialize(*)
  super
rescue Homebrew::CLI::MaxNamedArgumentsError
  raise UsageError, "Only one cask can be edited at a time."
end

Class Method Details

.descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


18
19
20
# File 'Library/Homebrew/cask/cmd/edit.rb', line 18

def self.description
  "Open the given <cask> for editing."
end

.max_namedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


14
15
16
# File 'Library/Homebrew/cask/cmd/edit.rb', line 14

def self.max_named
  1
end

.min_namedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


10
11
12
# File 'Library/Homebrew/cask/cmd/edit.rb', line 10

def self.min_named
  :cask
end

Instance Method Details

#cask_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


36
37
38
39
40
41
42
43
# File 'Library/Homebrew/cask/cmd/edit.rb', line 36

def cask_path
  casks.first.sourcefile_path
rescue CaskInvalidError, CaskUnreadableError, MethodDeprecatedError
  path = CaskLoader.path(args.first)
  return path if path.file?

  raise
end

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


28
29
30
31
32
33
34
# File 'Library/Homebrew/cask/cmd/edit.rb', line 28

def run
  exec_editor cask_path
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.freeze)
end