Module: T2Server::CLI
- Defined in:
- lib/t2-server-cli.rb
Instance Method Summary collapse
- #opts ⇒ Object
-
#parse_address(address, creds) ⇒ Object
separate the creds if they are supplied in the uri.
-
#register_options(banner) ⇒ Object
set up common options and return creds if provided.
Instance Method Details
#opts ⇒ Object
88 89 90 |
# File 'lib/t2-server-cli.rb', line 88 def opts @opts end |
#parse_address(address, creds) ⇒ Object
separate the creds if they are supplied in the uri
78 79 80 81 82 83 84 85 86 |
# File 'lib/t2-server-cli.rb', line 78 def parse_address(address, creds) if address == nil || address == "" puts @opts exit 1 end p_uri, p_creds = Util.strip_uri_credentials(address) creds != nil ? [p_uri, creds] : [p_uri, p_creds] end |
#register_options(banner) ⇒ Object
set up common options and return creds if provided
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/t2-server-cli.rb', line 41 def () user = nil pass = "" conn_params = DefaultConnectionParameters.new @opts = OptionParser.new do |opt| opt. = if block_given? yield opt end # SSL options ssl_auth_opts(opt, conn_params) ssl_transport_opts(opt, conn_params) # Simple credential options opt.on_tail("-u", "--username=USERNAME", "The username to use for " + "server operations.") do |val| user = val.chomp end opt.on_tail("-p", "--password=PASSWORD", "The password to use for " + "the supplied username.") do |val| pass = val.chomp end # Common options common_opts(opt) end # parse options @opts.parse! creds = user.nil? ? nil : HttpBasic.new(user, pass) [conn_params, creds] end |