Sha256: cbb830c5fba5ee6c54d088deb2c00c5105171b6b8f7005c418915770f2ce0d90

Contents?: true

Size: 1.14 KB

Versions: 18

Compression:

Stored size: 1.14 KB

Contents

module Brightbox
  desc I18n.t("config.desc")
  command [:config] do |cmd|
    cmd.desc I18n.t("config.client_add.desc")
    cmd.arg_name "client-id secret [api_url, auth_url]"
    cmd.command [:client_add] do |c|
      c.desc "client alias (local reference)"
      c.flag [:a, "alias"]

      c.desc "auth url"
      c.flag [:t, "auth-url"]

      c.action do |_global_options, options, args|
        info "Using config file #{Brightbox.config.config_filename}"

        client_id = args.shift
        secret = args.shift
        api_url = args.shift || DEFAULT_API_ENDPOINT
        auth_url = args.shift || api_url

        calias = options[:a] || client_id

        if client_id.nil?
          raise "You must specify the client-id"
        end

        unless client_id[/^cli-.{5}$/]
          raise "The client-id '#{client_id}' must match the format cli-xxxxx"
        end

        if secret.nil?
          raise "You must specify the client secret"
        end

        options = {
          :api_url => api_url,
          :auth_url => auth_url
        }
        Brightbox.config.add_section(calias, client_id, secret, options)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-5.0.0.rc2 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-5.0.0.rc1 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-5.0.0.alpha lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.8.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.7.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.6.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.5.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.4.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.3.2 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.3.1 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.3.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.2.1 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.2.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.1.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.0.0 lib/brightbox-cli/commands/config/client_add.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/commands/config/client_add.rb