Sha256: ce12740f41bed69b491878b7a66d2f16ffe6b4fe665e111ba7563ae6523dea52

Contents?: true

Size: 922 Bytes

Versions: 6

Compression:

Stored size: 922 Bytes

Contents

module Brightbox
  desc "Authentication token management"
  command [:token] do |cmd|
    cmd.default_command :show

    cmd.desc "Show currently cached OAuth2 Bearer token"
    cmd.command [:show] do |c|
      c.desc "Either 'text', 'token', 'json' or 'curl'"
      c.arg_name "format"
      c.default_value "text"
      c.flag [:format]

      c.action do |_, options, _|
        token = Token.show(Brightbox.config, options)
        $stdout.puts token.format(options[:format] || "text")
      end
    end

    cmd.desc "Create new OAuth2 Bearer token"
    cmd.command [:create] do |c|
      c.desc "Either 'text', 'token', 'json' or 'curl'"
      c.arg_name "format"
      c.default_value "text"
      c.flag [:format]

      c.action do |_, options, _|
        config.reauthenticate
        token = Token.show(Brightbox.config, options)
        $stdout.puts token.format(options[:format])
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 lib/brightbox-cli/commands/token.rb
brightbox-cli-3.2.0 lib/brightbox-cli/commands/token.rb
brightbox-cli-3.1.0 lib/brightbox-cli/commands/token.rb
brightbox-cli-3.0.1 lib/brightbox-cli/commands/token.rb
brightbox-cli-3.0.0 lib/brightbox-cli/commands/token.rb
brightbox-cli-2.12.0 lib/brightbox-cli/commands/token.rb