Module: ORS::Command::ClassMethods

Includes:
ORS::Commands
Included in:
ORS::Command
Defined in:
lib/ors/command.rb

Instance Method Summary collapse

Instance Method Details

#run(args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ors/command.rb', line 12

def run args
  command, *options = args
  klass = command.to_s.capitalize

  if command =~ /-*version/i
    puts "ORS v#{ORS::VERSION}"
  else
    if available_commands.include? klass
      ORS::Config.parse_options options
      ORS::Config.parse_config_file

      if ORS::Config.valid_options?
        Base.run ORS::Commands.const_get(klass)
      else
        info "ERROR: Invalid options given."
        Base.run Help
      end
    else
      Base.run Help
    end
  end
end