# frozen_string_literal: true require 'thor' require "pastel" require "tty-font" module Dri # Handle the application command line parsing # and the dispatch to various command objects # # @api public class CLI < Thor # Error raised by this runner Error = Class.new(StandardError) def self.exit_on_failure? true end def help(*args) font = TTY::Font.new(:doom) pastel = Pastel.new(enabled: !options[:no_color]) puts pastel.yellow(font.write("DRI")) super end class_option :no_color, type: :boolean, default: false, desc: "Disable colorization in output" desc 'version', 'dri version' def version require_relative 'version' puts "v#{Dri::VERSION}" end map %w[--version -v] => :version desc 'incidents', 'View current incidents' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def incidents(*) if options[:help] invoke :help, ['incidents'] else require_relative 'commands/incidents' Dri::Commands::Incidents.new(options).execute end end require_relative 'commands/rm' register Dri::Commands::Rm, 'rm', 'rm [SUBCOMMAND]', 'Remove triage-related items' desc 'profile', 'View current user settings' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :edit, type: :string, banner: "editor", desc: "Open the holdings configuration file for " \ "editing in EDITOR, or the default editor " \ "if not specified." def profile(*) if options[:help] invoke :help, ['profile'] else require_relative 'commands/profile' Dri::Commands::Profile.new(options).execute end end desc 'init', 'Create a configuration to use dri' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def init(*) if options[:help] invoke :help, ['init'] else require_relative 'commands/init' Dri::Commands::Init.new(options).execute end end require_relative 'commands/fetch' register Dri::Commands::Fetch, 'fetch', 'fetch [SUBCOMMAND]', 'Fetch failures & testcases' require_relative 'commands/publish' register Dri::Commands::Publish, 'publish', 'publish [SUBCOMMAND]', 'Publish report for handover' require_relative 'commands/analyze' register Dri::Commands::Analyze, 'analyze', 'analyze [SUBCOMMAND]', 'Analysis of test failures and issues' end end