Class: RbVmomi::VIM::EsxcliCommand
- Inherits:
-
Object
- Object
- RbVmomi::VIM::EsxcliCommand
- Defined in:
- lib/rvc/extensions/HostSystem.rb
Instance Method Summary collapse
Instance Method Details
#option_parser ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/rvc/extensions/HostSystem.rb', line 184 def option_parser parser = Trollop::Parser.new parser.text cli_info.help cli_info.param.each do |cli_param| vmodl_param = type_info.paramTypeInfo.find { |x| x.name == cli_param.name } opts = trollop_type(vmodl_param.type) opts[:required] = vmodl_param.annotation.find { |a| a.name == "optional"} ? false : true opts[:long] = cli_param.displayName #pp opts.merge(:name => cli_param.name) # XXX correct short options parser.opt cli_param.name, cli_param.help, opts end parser end |
#trollop_type(t) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/rvc/extensions/HostSystem.rb', line 199 def trollop_type t if t[-2..-1] == '[]' multi = true t = t[0...-2] else multi = false end type = case t when 'string', 'boolean' then t.to_sym when 'long' then :int else fail "unexpected esxcli type #{t.inspect}" end { :type => type, :multi => multi } end |