Module: Simple::CLI::H

Defined in:
lib/simple/cli.rb

Class Method Summary collapse

Class Method Details

.action_for_command(service, command) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/simple/cli.rb', line 91

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



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

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



111
112
113
# File 'lib/simple/cli.rb', line 111

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

.command_to_action(command) ⇒ Object



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

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

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