Sha256: c909d0c195ed0b69aa344f7dd38d2dbcd1925191c897fae0e1b188d0e6d29bc0

Contents?: true

Size: 1.04 KB

Versions: 36

Compression:

Stored size: 1.04 KB

Contents

require "cf/cli/app/base"

module CF::App
  class Events < Base
    desc "Display application events"
    group :apps, :info
    input :app, :desc => "Application to get the events for",
          :argument => true, :from_given => by_name(:app)
    def events
      app = input[:app]

      events =
        with_progress("Getting events for #{c(app.name, :name)}") do
          format_events(app.events)
        end

      line unless quiet?
      table(%w{time instance\ index description exit\ status}, events)

    end

    private

    def sort_events(events)
      events.sort_by { |event| DateTime.parse(event.timestamp) }
    end

    def format_events(events)
      sort_events(events).map do |event|
        [event.timestamp,
         c(event.instance_index.to_s, :warning),
         event.exit_description,
         format_status(event)]
      end
    end

    def format_status(event)
      if event.exit_status == 0
        c("Success (#{event.exit_status})", :good)
      else
        c("Failure (#{event.exit_status})", :bad)
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
cf-5.4.7 lib/cf/cli/app/events.rb
cf-5.4.7.rc1 lib/cf/cli/app/events.rb
cf-5.4.5 lib/cf/cli/app/events.rb
cf-5.4.4 lib/cf/cli/app/events.rb
trucker-cli-0.0.3 lib/cf/cli/app/events.rb
cf-5.4.3 lib/cf/cli/app/events.rb
cf-5.4.2 lib/cf/cli/app/events.rb
trucker-cli-0.0.2 lib/cf/cli/app/events.rb
trucker-cli-0.0.1 lib/cf/cli/app/events.rb
cf-5.4.1 lib/cf/cli/app/events.rb
cf-5.4.1.rc1 lib/cf/cli/app/events.rb
cf-5.4.0 lib/cf/cli/app/events.rb
cf-5.3.1 lib/cf/cli/app/events.rb
cf-5.3.0 lib/cf/cli/app/events.rb
cf-5.2.2 lib/cf/cli/app/events.rb
cf-5.2.1.rc15 lib/cf/cli/app/events.rb
cf-5.2.1.rc14 lib/cf/cli/app/events.rb
cf-5.2.1.rc13 lib/cf/cli/app/events.rb
cf-5.2.1.rc12 lib/cf/cli/app/events.rb
cf-5.2.1.rc11 lib/cf/cli/app/events.rb