Class: BranchIOCLI::Command::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/branch_io_cli/command/command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Command

Returns a new instance of Command.



32
33
34
35
# File 'lib/branch_io_cli/command/command.rb', line 32

def initialize(options)
  @options = options
  @config = self.class.configuration_class.new options
end

Instance Attribute Details

#configObject (readonly)

command-specific configuration object



30
31
32
# File 'lib/branch_io_cli/command/command.rb', line 30

def config
  @config
end

#optionsObject (readonly)

command-specific options from CLI



29
30
31
# File 'lib/branch_io_cli/command/command.rb', line 29

def options
  @options
end

Class Method Details

.available_optionsObject



16
17
18
# File 'lib/branch_io_cli/command/command.rb', line 16

def available_options
  configuration_class.available_options
end

.command_nameObject



5
6
7
8
# File 'lib/branch_io_cli/command/command.rb', line 5

def command_name
  matches = /BranchIOCLI::Command::(\w+)Command/.match name
  matches[1].downcase
end

.configuration_classObject



10
11
12
13
14
# File 'lib/branch_io_cli/command/command.rb', line 10

def configuration_class
  root = command_name.capitalize

  BranchIOCLI::Configuration.const_get("#{root}Configuration")
end

.examplesObject



20
21
22
# File 'lib/branch_io_cli/command/command.rb', line 20

def examples
  configuration_class.examples if configuration_class.respond_to?(:examples)
end

.return_valueObject



24
25
26
# File 'lib/branch_io_cli/command/command.rb', line 24

def return_value
  configuration_class.return_value if configuration_class.respond_to?(:return_value)
end

Instance Method Details

#envObject



53
54
55
# File 'lib/branch_io_cli/command/command.rb', line 53

def env
  Configuration::Environment
end

#helperObject



41
42
43
# File 'lib/branch_io_cli/command/command.rb', line 41

def helper
  Helper::BranchHelper
end

#patch_helperObject



45
46
47
# File 'lib/branch_io_cli/command/command.rb', line 45

def patch_helper
  Helper::PatchHelper
end

#run!Object



37
38
39
# File 'lib/branch_io_cli/command/command.rb', line 37

def run!
  # implemented by subclasses
end

#tool_helperObject



49
50
51
# File 'lib/branch_io_cli/command/command.rb', line 49

def tool_helper
  Helper::ToolHelper
end