Sha256: 0ed47d8772adb66b2e639c5733f3cb2e92e73089c07e4f2f447641c53168b3f3

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 KB

Contents

require 'aptible/auth'
require 'thor'
require 'json'

require_relative 'helpers/token'
require_relative 'helpers/operation'
require_relative 'helpers/account'
require_relative 'helpers/app'

require_relative 'subcommands/apps'
require_relative 'subcommands/config'
require_relative 'subcommands/db'
require_relative 'subcommands/logs'
require_relative 'subcommands/rebuild'
require_relative 'subcommands/restart'
require_relative 'subcommands/ssh'

module Aptible
  module CLI
    class Agent < Thor
      include Thor::Actions

      include Helpers::Token
      include Subcommands::Apps
      include Subcommands::Config
      include Subcommands::DB
      include Subcommands::Rebuild
      include Subcommands::Restart
      include Subcommands::SSH
      include Subcommands::Tail

      desc 'version', 'Print Aptible CLI version'
      def version
        puts "aptible-cli v#{Aptible::CLI::VERSION}"
      end

      desc 'login', 'Log in to Aptible'
      option :email
      option :password
      def login
        email = options[:email] || ask('Email: ')
        password = options[:password] || ask('Password: ', echo: false)
        puts ''

        begin
          token = Aptible::Auth::Token.create(email: email, password: password)
        rescue OAuth2::Error
          raise Thor::Error, 'Could not authenticate with given credentials'
        end

        save_token(token.access_token)
        puts "Token written to #{token_file}"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
aptible-cli-0.5.7 lib/aptible/cli/agent.rb
aptible-cli-0.5.6 lib/aptible/cli/agent.rb
aptible-cli-0.5.5 lib/aptible/cli/agent.rb
aptible-cli-0.5.4 lib/aptible/cli/agent.rb
aptible-cli-0.5.2 lib/aptible/cli/agent.rb
aptible-cli-0.5.1 lib/aptible/cli/agent.rb
aptible-cli-0.5.0 lib/aptible/cli/agent.rb
aptible-cli-0.4.4 lib/aptible/cli/agent.rb