Sha256: ae9264ab6e95480ddeadb6afd7b8cc2daa9148276cbe2a3f9095ed251e2e987f

Contents?: true

Size: 990 Bytes

Versions: 6

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

require 'travis/cli'

module Travis
  module CLI
    class Accounts < ApiCommand
      description 'displays accounts and their subscription status'

      def run
        authenticate
        accounts.each do |account|
          color = account.on_trial? ? :info : :green
          say [
            color(account.login, [color, :bold]),
            color("(#{account.name || account.login.capitalize}):", color),
            "#{description(account)},",
            account.repos_count == 1 ? '1 repository' : "#{account.repos_count} repositories"
          ].join(' ')
        end
        return if accounts.none?(&:on_trial?) || session.config['host'].nil?

        say session.config['host'], 'To set up a subscription, please visit %s.'
      end

      def description(account)
        return 'subscribed'          if account.subscribed?
        return 'educational account' if account.educational?

        'not subscribed'
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
travis-1.14.0 lib/travis/cli/accounts.rb
travis-1.13.3 lib/travis/cli/accounts.rb
travis-1.13.2 lib/travis/cli/accounts.rb
travis-1.13.1 lib/travis/cli/accounts.rb
travis-1.13.0 lib/travis/cli/accounts.rb
travis-1.12.0 lib/travis/cli/accounts.rb