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
93 94 95 |
# File 'lib/t2-server-cli.rb', line 93 def opts @opts end |
#parse_address(address, creds) ⇒ Object
separate the creds if they are supplied in the uri
83 84 85 86 87 88 89 90 91 |
# File 'lib/t2-server-cli.rb', line 83 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 76 77 78 79 80 |
# 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) # common 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 opt.on_tail("-h", "-?", "--help", "Show this help message.") do puts opt exit end opt.on_tail("-v", "--version", "Show the version.") do puts "Taverna 2 Server Ruby Gem version: #{T2Server::Version::STRING}" exit end end # parse options @opts.parse! creds = user.nil? ? nil : HttpBasic.new(user, pass) [conn_params, creds] end |