From 7f9db265b43d8650d234c9f1d1ef2a6e179ff4ec Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 17 Aug 2022 18:49:21 +0200 Subject: [PATCH] Add support for colors --- exe/collect-repos | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/exe/collect-repos b/exe/collect-repos index db95e64..50d0f47 100755 --- a/exe/collect-repos +++ b/exe/collect-repos @@ -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