Sha256: c5f71850adad7d87a5ad312c03f9beb902469758095e5c9eec4a373f197613b0
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true require_relative '../command' require_relative '../utils/table' module Dri module Commands class Incidents < Dri::Command include Dri::Utils::Table using Refinements def initialize(options) @options = options end def execute(input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize verify_config_exists incident = add_color('Incident', :bright_yellow) service = add_color('Service', :bright_yellow) status = add_color('Status', :bright_yellow) url = add_color('URL', :bright_yellow) header = [incident, service, status, url] logger.info "Looking for open incidents..." incidents = [] spinner.run do response = api_client.incidents if response.nil? logger.info 'Hooray, no active incidents 🎉.' exit 0 end response.each do |incident| title = incident['title'].truncate(70) url = incident['web_url'] labels = incident['labels'] status = "N/A" service = "N/A" labels.each do |label| status = label.gsub!('Incident::', ' ').to_s if label.include? "Incident::" service = label.gsub!('Service::', ' ').to_s if label.include? "Service::" end incidents << [title, service, status, url] end end print_table(header, incidents, alignments: [:left, :center, :center, :center]) output.puts(<<~MSG) Found: #{incidents.size} incident(s). MSG end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dri-0.3.1 | lib/dri/commands/incidents.rb |
dri-0.3.0 | lib/dri/commands/incidents.rb |