Module: Simple::CLI::H

Defined in:
lib/simple/cli.rb

Class Method Summary collapse

Class Method Details

.action_for_command(service, command) ⇒ Object



107
108
109
110
111
112
113
# File 'lib/simple/cli.rb', line 107

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



115
116
117
118
119
# File 'lib/simple/cli.rb', line 115

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



127
128
129
# File 'lib/simple/cli.rb', line 127

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

.command_to_action(command) ⇒ Object



121
122
123
124
125
# File 'lib/simple/cli.rb', line 121

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

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