Method: Commands.run

Defined in:
lib/commands-lite/base.rb

.run(args = []) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/commands-lite/base.rb', line 103

def self.run( args=[] )
  command_name = args.shift

  ## 1) downcase  e.g. GithubStats

  ## 2) remove - to _   ## treat them the same e.g. github-stats => github_stats

  command_name = command_name
                   .gsub( /[_-]/, '' )
                   .downcase

  command = commands[ command_name ]
  if command.nil?
    puts "!! ERROR: no command definition found for >#{command_name}<; known commands include:"
    pp commands
    exit 1
  end

  command.run( args )
end