Class: Vcloud::Walker::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/walker/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv_array) ⇒ Cli

Returns a new instance of Cli.



7
8
9
10
11
12
13
14
15
# File 'lib/vcloud/walker/cli.rb', line 7

def initialize(argv_array)
  @usage_text = nil
  @resource_type = nil
  @options = {
    :yaml => false,
  }

  parse(argv_array)
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vcloud/walker/cli.rb', line 17

def run
  begin
    out = Vcloud::Walker.walk(@resource_type)
    if @options[:yaml]
      print(out.to_yaml)
    else
      print(JSON.pretty_generate(out))
    end
  rescue => e
    $stderr.puts(e)
    exit 1
  end
end