Module: Simple::CLI::H

Defined in:
lib/simple/cli.rb

Class Method Summary collapse

Class Method Details

.action_for_command(service, command) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/simple/cli.rb', line 98

def self.action_for_command(service, command)
  actions = ::Simple::Service.actions(service)

  action_name = H.command_to_action(command)
  return nil unless actions.key?(action_name)
  actions[action_name]
end

.action_to_command(action_name) ⇒ Object



106
107
108
109
110
# File 'lib/simple/cli.rb', line 106

def self.action_to_command(action_name)
  raise "action_name must by a Symbol" unless action_name.is_a?(Symbol)

  action_name.to_s.tr("_", ":")
end

.binary_nameObject



118
119
120
# File 'lib/simple/cli.rb', line 118

def self.binary_name
  $0.gsub(/.*\//, "")
end

.command_to_action(command) ⇒ Object



112
113
114
115
116
# File 'lib/simple/cli.rb', line 112

def self.command_to_action(command)
  raise "command must by a String" unless command.is_a?(String)

  command.tr(":", "_").to_sym
end