Sha256: 5f8bfcc208327c123a2e52f874406dfe7591126fa1664d4d69346f981f056456

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require 'shellwords'

module Aptible
  module CLI
    module Subcommands
      module Logs
        def self.included(thor)
          thor.class_eval do
            include Helpers::Operation
            include Helpers::App
            include Helpers::Database

            desc 'logs', 'Follows logs from a running app or database'
            app_options
            option :database
            def logs
              if options[:app] && options[:database]
                m = 'You must specify only one of --app and --database'
                raise Thor::Error, m
              end

              resource = \
                if options[:database]
                  ensure_database(options.merge(db: options[:database]))
                else
                  ensure_app(options)
                end

              unless resource.status == 'provisioned'
                raise Thor::Error, 'Unable to retrieve logs. ' \
                                   "Have you deployed #{resource.handle} yet?"
              end

              op = resource.create_operation!(type: 'logs', status: 'succeeded')

              ENV['ACCESS_TOKEN'] = fetch_token
              exit_with_ssh_portal(op, '-o', 'SendEnv=ACCESS_TOKEN', '-T')
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aptible-cli-0.13.0 lib/aptible/cli/subcommands/logs.rb
aptible-cli-0.12.0 lib/aptible/cli/subcommands/logs.rb
aptible-cli-0.11.2 lib/aptible/cli/subcommands/logs.rb
aptible-cli-0.11.1 lib/aptible/cli/subcommands/logs.rb
aptible-cli-0.11.0 lib/aptible/cli/subcommands/logs.rb