Sha256: 2ca56237fb42f60c65dc68dac4281bd39d8718271c33ceee901ff46ca8079f58
Contents?: true
Size: 1.63 KB
Versions: 12
Compression:
Stored size: 1.63 KB
Contents
module Brightbox command [:config] do |cmd| cmd.desc I18n.t("config.user_add.desc") cmd.arg_name "email client-id secret [api_url auth_url]" cmd.command [:user_add] do |c| c.desc "client alias (local reference)" c.flag [:a, "alias"] c.desc "password, if not specified you will be prompted" c.flag [:p, "password"] c.action do |_global_options, options, args| require 'highline' info "Using config file #{$config.config_filename}" email = args.shift client_id = args.shift secret = args.shift api_url = args.shift || DEFAULT_API_ENDPOINT auth_url = args.shift || api_url calias = options[:a] || email password = options[:p] if email.nil? raise "You must specify your user's email address" end if client_id.nil? raise "You must specify the client-id" end unless client_id[/^app-.{5}$/] raise "The client-id '#{client_id}' must match the format app-xxxxx" end if secret.nil? raise "You must specify the client secret" end if !password || password.empty? highline = HighLine.new password = highline.ask("Enter your password : ") { |q| q.echo = false } end if password.empty? raise "You must specify your Brightbox password." end options = { :username => email, :password => password, :api_url => api_url, :auth_url => auth_url } $config.add_section(calias, client_id, secret, options) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems