Sha256: d1ac232727837e0e9b247c65586c4da498613d4d8a8c7a8933d7b7da5f282b3d

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'routemaster/cli/base'

module Routemaster
  module CLI
    module Token
      class Add < Base
        prefix %w[token add]
        syntax 'SERVICE [TOKEN]'
        descr %{
          Adds `TOKEN` to the list of API tokens permitted to use the bus API. `SERVICE`
          is a human-readable name for this token.
        }

        action do
          bad_argc! unless (1..2).include? argv.length

          service, token = argv
          puts helper.client.token_add(name: service, token: token)
        end
      end

      class Del < Base
        prefix %w[token del]
        syntax 'TOKEN'
        descr %{
          Removes `TOKEN` from permitted tokens if it exists.
        }

        action do
          bad_argc! unless argv.length == 1

          helper.client.token_del(token: argv.first)
        end
      end

      class List < Base
        prefix %w[token list]
        descr %{
          Lists currently permitted API tokens.
        }

        action do
          bad_argc! unless argv.length == 0

          helper.client.token_list.each do |t,n|
            puts "#{t}\t#{n}"
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
routemaster-client-3.2.3 routemaster/cli/token.rb
routemaster-client-3.2.0 routemaster/cli/token.rb
routemaster-client-3.1.2 routemaster/cli/token.rb
routemaster-client-3.1.1 routemaster/cli/token.rb