Sha256: 27e145d573f913aa3a45354f7e2943b609ca47199bce09f5703e09a9eb62f860
Contents?: true
Size: 1.69 KB
Versions: 5
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true require_relative '../command' require_relative '../utils/table' require_relative '../utils/constants' module Dri module Commands class Incidents < Dri::Command include Dri::Utils::Table include Dri::Utils::Constants::Triage::Labels 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 🎉.' break 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
5 entries across 5 versions & 1 rubygems