Class: Cask::Cmd::AbstractCommand Private

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Includes:
Homebrew::Search
Defined in:
cask/cmd/abstract_command.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Abstract superclass for all Cask implementations of commands.

Direct Known Subclasses

Audit, Fetch, Info, Install, List, Uninstall, Upgrade, Zap

Constant Summary collapse

OPTIONS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

[
  [:switch, "--[no-]binaries", {
    description: "Disable/enable linking of helper executables (default: enabled).",
    env:         :cask_opts_binaries,
  }],
  [:switch, "--require-sha",  {
    description: "Require all casks to have a checksum.",
    env:         :cask_opts_require_sha,
  }],
  [:switch, "--[no-]quarantine", {
    description: "Disable/enable quarantining of downloads (default: enabled).",
    env:         :cask_opts_quarantine,
  }],
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Homebrew::Search

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

Methods included from Homebrew::Search::Extension

#search_casks, #search_descriptions

Constructor Details

#initialize(*args) ⇒ AbstractCommand

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns a new instance of AbstractCommand.



73
74
75
# File 'cask/cmd/abstract_command.rb', line 73

def initialize(*args)
  @args = self.class.parser.parse(args)
end

Instance Attribute Details

#argsObject (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



71
72
73
# File 'cask/cmd/abstract_command.rb', line 71

def args
  @args
end

Class Method Details

.abstract?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


48
49
50
# File 'cask/cmd/abstract_command.rb', line 48

def self.abstract?
  name.split("::").last.match?(/^Abstract[^a-z]/)
end

.command_nameString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



43
44
45
# File 'cask/cmd/abstract_command.rb', line 43

def self.command_name
  @command_name ||= name.sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1_\2').downcase
end

.helpString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



58
59
60
# File 'cask/cmd/abstract_command.rb', line 58

def self.help
  parser.generate_help_text
end

.parser(&block) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



32
33
34
35
36
37
38
39
40
# File 'cask/cmd/abstract_command.rb', line 32

def self.parser(&block)
  Cmd.parser do
    instance_eval(&block) if block

    OPTIONS.each do |option|
      send(*option)
    end
  end
end

.run(*args) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



67
68
69
# File 'cask/cmd/abstract_command.rb', line 67

def self.run(*args)
  new(*args).run
end

.short_descriptionString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



63
64
65
# File 'cask/cmd/abstract_command.rb', line 63

def self.short_description
  description[/\A[^.]*\./]
end

.visible?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


53
54
55
# File 'cask/cmd/abstract_command.rb', line 53

def self.visible?
  true
end