Sha256: 09d80593a35ddc2517ea3de33c0fe0efbfa7a1072c00b5bbe41fdd10a4247af1

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

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

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

require_relative 'subcommands/config'
require_relative 'subcommands/ssh'
require_relative 'subcommands/tunnel'

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

      include Helpers::Token
      include Subcommands::Config
      include Subcommands::SSH
      include Subcommands::Tunnel

      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

1 entries across 1 versions & 1 rubygems

Version Path
aptible-cli-0.3.4 lib/aptible/cli/agent.rb