From 4f068d2151e2803c4a5c742423814146b8d3c246 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 28 Jan 2015 14:03:26 -0800 Subject: [PATCH] allow --no-color option to cli --- bin/gman | 3 ++- test/test_gman_bin.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/gman b/bin/gman index a2412396..add4bb0b 100755 --- a/bin/gman +++ b/bin/gman @@ -14,9 +14,10 @@ class IsoCountryCodes end domain = ARGV[0] +String.disable_colorization = true if ARGV[1] == "--no-color" if domain.nil? - puts "USAGE: gman ".red + puts "USAGE: gman [--no-color]".red exit 1 end diff --git a/test/test_gman_bin.rb b/test/test_gman_bin.rb index 06675c39..e2e3032f 100644 --- a/test/test_gman_bin.rb +++ b/test/test_gman_bin.rb @@ -53,4 +53,13 @@ def setup assert_match /DC/, @output assert_equal 0, @status.exitstatus end + + should "allow you to disable colorization" do + output, status = test_bin("whitehouse.gov", "--no-color") + refute_match /\[0;32;49m/, output + end + + should "color by default" do + assert_match /\[0;32;49m/, @output + end end