Sha256: 27ccbc72ba45e7dd9258c4a73d76151b08462a4b6d2002e195613cffc01cdb62

Contents?: true

Size: 1.06 KB

Versions: 41

Compression:

Stored size: 1.06 KB

Contents

require "cf/cli/app/base"

module CF::App
  class Events < Base
    desc "Display application events"
    group :apps, :info, :hidden => true
    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

41 entries across 41 versions & 1 rubygems

Version Path
cf-4.2.9.rc5 lib/cf/cli/app/events.rb
cf-4.2.9.rc3 lib/cf/cli/app/events.rb
cf-4.2.9.rc2 lib/cf/cli/app/events.rb
cf-4.2.8 lib/cf/cli/app/events.rb
cf-4.2.8.rc2 lib/cf/cli/app/events.rb
cf-4.2.8.rc1 lib/cf/cli/app/events.rb
cf-4.2.7 lib/cf/cli/app/events.rb
cf-4.2.6 lib/cf/cli/app/events.rb
cf-4.2.5 lib/cf/cli/app/events.rb
cf-4.2.4 lib/cf/cli/app/events.rb
cf-4.2.3 lib/cf/cli/app/events.rb
cf-4.2.2.rc3 lib/cf/cli/app/events.rb
cf-4.2.2.rc2 lib/cf/cli/app/events.rb
cf-4.2.2.rc1 lib/cf/cli/app/events.rb
cf-4.2.1 lib/cf/cli/app/events.rb
cf-4.2.1.rc3 lib/cf/cli/app/events.rb
cf-4.2.1.rc2 lib/cf/cli/app/events.rb
cf-4.2.1.rc1 lib/cf/cli/app/events.rb
cf-4.2.0 lib/cf/cli/app/events.rb
cf-4.1.5.rc7 lib/cf/cli/app/events.rb