lib/vcloud/core/login_cli.rb
# Create a new instance of the CLI, parsing the arguments supplied
#
# @param argv_array [Array] The Array of ARGV arguments
# @return [Vcloud::Core::LoginCLI]
Create a new instance of the CLI, parsing the arguments supplied
Create a new instance of the CLI parsing the arguments supplied
def parse(args)
        opt_parser = OptionParser.new do |opts|
          opts.banner = <<-EOS
Usage: #{$0} [options]
Utility for obtaining a Fog vCloud Director session token. It will output a
shell `export` command that can be consumed with:
    eval $(FOG_CREDENTIAL=example #{$0})
It requires a Fog credentials file (e.g. `~/.fog`) with the host and user
set, but the password set to an empty string. The password can either be
entered interactively or piped in, for example from an environment variable:
    printenv PASSWORD_VAR | FOG_CREDENTIAL=example #{$0}
          EOS
          opts.on("-h", "--help", "Print usage and exit") do
            $stderr.puts opts
            exit
          end
          opts.on("--version", "Display version and exit") do
            puts Vcloud::Core::VERSION
            exit
          end
        end
        @usage_text = opt_parser.to_s
        begin
          opt_parser.parse!(args)
        rescue OptionParser::InvalidOption => e
          exit_error_usage(e)
        end
        if args.size > 0
          exit_error_usage("too many arguments")
        elsif args.size == 1
          @type = args.first
        end
      end
def parse ( args ) opt_parser = OptionParser . new do | opts | opts . banner = <<-EOS 
Usage:  #{ $0 }  [options]

Utility for obtaining a Fog vCloud Director session token. It will output a
shell `export` command that can be consumed with:

    eval $(FOG_CREDENTIAL=example  #{ $0 } )

It requires a Fog credentials file (e.g. `~/.fog`) with the host and user
set, but the password set to an empty string. The password can either be
entered interactively or piped in, for example from an environment variable:

    printenv PASSWORD_VAR | FOG_CREDENTIAL=example  #{ $0 } EOS opts . on ( "-h" , "--help" , "Print usage and exit" ) do $stderr . puts opts exit end opts . on ( "--version" , "Display version and exit" ) do puts Vcloud :: Core :: VERSION exit end end @usage_text = opt_parser . to_s begin opt_parser . parse! ( args ) rescue OptionParser :: InvalidOption => e exit_error_usage ( e ) end if args . size > 0 exit_error_usage ( "too many arguments" ) elsif args . size == 1 @type = args . first end end
Create a new instance of the CLI, parsing the arguments supplied
Create a new instance of the CLI parsing the arguments supplied
None
Vcloud::Core::LoginCLI
args
argv_array
The Array of ARGV arguments
The Array of ARGV arguments