From 1daf5d2cb63145408520f39c799425a82b2ec948 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sat, 11 Aug 2018 19:54:10 -0600 Subject: First pass at improved colorizing - colors setting now allows Always, Terminal, Never values - poutput() and perror() honor these new settings --- tests/conftest.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py index 3f3b862e..9ca506af 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -80,11 +80,8 @@ SHORTCUTS_TXT = """Shortcuts for other commands: @@: _relative_load """ -expect_colors = True -if sys.platform.startswith('win'): - expect_colors = False # Output from the show command with default settings -SHOW_TXT = """colors: {} +SHOW_TXT = """colors: Terminal continuation_prompt: > debug: False echo: False @@ -94,14 +91,10 @@ locals_in_py: False prompt: (Cmd) quiet: False timing: False -""".format(expect_colors) +""" -if expect_colors: - color_str = 'True ' -else: - color_str = 'False' SHOW_LONG = """ -colors: {} # Colorized output (*nix only) +colors: Terminal # Allow colorized output continuation_prompt: > # On 2nd+ line of input debug: False # Show full error stack on error echo: False # Echo command issued into output @@ -111,7 +104,7 @@ locals_in_py: False # Allow access to your application in py via self prompt: (Cmd) # The prompt issued to solicit input quiet: False # Don't print nonessential feedback timing: False # Report execution times -""".format(color_str) +""" class StdOut(object): @@ -128,6 +121,9 @@ class StdOut(object): def clear(self): self.buffer = '' + def isatty(self): + return True + def normalize(block): """ Normalize a block of text to perform comparison. -- cgit v1.2.1 From ccbe1276f786e94f1996877fdec6d070705f5ab8 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Wed, 19 Sep 2018 15:32:37 -0400 Subject: cmd2.Cmd.__init__ now initializes colorama and tells it to never strip ANSI codes since cmd2 deals with that Also: - Finished editing poutput(), ppaged(), and pfeedback() methods to strip ANSI color when appropriate - Changed attr.ib() factory usage so cmd2 is compatible with older versions of attrs --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py index c86748e8..e177496b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -94,7 +94,7 @@ timing: False """ SHOW_LONG = """ -colors: Terminal # Allow colorized output +colors: Terminal # Allow colorized output (valid values: Terminal, Always, Never) continuation_prompt: > # On 2nd+ line of input debug: False # Show full error stack on error echo: False # Echo command issued into output -- cgit v1.2.1