Class: Enviera::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/enviera/CLI.rb

Class Method Summary collapse

Class Method Details

.executeObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/enviera/CLI.rb', line 38

def self.execute

  executor = Enviera::Options[:executor]
  begin
    result = executor.execute
    puts result unless result.nil?
  rescue Exception => e
    Utils.warn e.message
    Utils.debug e.backtrace.join("\n")
  end

end

.parseObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/enviera/CLI.rb', line 10

def self.parse

  Utils.require_dir 'enviera/subcommands'
  Enviera.subcommands = Utils.find_all_subclasses_of({ :parent_class => Enviera::Subcommands }).collect {|classname| Utils.snakecase classname}

  Enviera.subcommand = ARGV.shift
  subcommand = case Enviera.subcommand
  when nil
    ARGV.delete_if {true}
    "unknown_command"
  when /^\-/
    ARGV.delete_if {true}
    "help"
  else
    Enviera.subcommand
  end

  command_class = Subcommand.find subcommand

  options = command_class.parse
  options[:executor] = command_class

  options = command_class.validate options
  Enviera::Options.set options
  Enviera::Options.trace

end