Add support for colors

This commit is contained in:
Glenn Y. Rolland 2022-08-17 18:49:21 +02:00
parent 3fdc373eec
commit 7f9db265b4

View file

@ -7,13 +7,18 @@ require 'find'
require 'thor'
require 'table_print'
require 'tty-spinner'
require 'colorize'
class ListRepos < Thor
desc 'list [SELECTOR]', 'List repositories'
method_option :root, type: :string, aliases: '-r'
def list(selector_str="")
def initialize(*args)
String.disable_colorization = true unless ENV['NO_COLOR'].nil?
super
end
basedir = options['root'] || '.'
projects = []
spinner = TTY::Spinner.new(
@ -22,8 +27,8 @@ class ListRepos < Thor
)
selector = self.class.build_selector(selector_str)
selector_str2 = selector.map { |k, v| "#{k}=#{v}" }.join(' ')
puts "selector = #{selector_str2}"
selector_str2 = selector.map { |k, v| "#{k}=#{v.to_s.colorize(:yellow)}" }.join(' AND ')
puts "SELECTOR: #{selector_str2}"
## COLLECT
spinner.auto_spin