From e8206628eefe8234cb5118807c6f40e983c2a316 Mon Sep 17 00:00:00 2001 From: xNinjaKittyx Date: Mon, 24 Jun 2019 17:54:15 -0700 Subject: Initial Commit for Issue 698 --- examples/python_scripting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/python_scripting.py') diff --git a/examples/python_scripting.py b/examples/python_scripting.py index c45648bc..f9461fa5 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -56,7 +56,7 @@ class CmdLineApp(cmd2.Cmd): """ # Expect 1 argument, the directory to change to if not arglist or len(arglist) != 1: - self.perror("cd requires exactly 1 argument:", traceback_war=False) + self.pexcept("cd requires exactly 1 argument:", traceback_war=False) self.do_help('cd') self.last_result = cmd2.CommandResult('', 'Bad arguments') return @@ -83,7 +83,7 @@ class CmdLineApp(cmd2.Cmd): data = path if err: - self.perror(err, traceback_war=False) + self.pexcept(err, traceback_war=False) self.last_result = cmd2.CommandResult(out, err, data) # Enable tab completion for cd command @@ -98,7 +98,7 @@ class CmdLineApp(cmd2.Cmd): """List contents of current directory.""" # No arguments for this command if unknown: - self.perror("dir does not take any positional arguments:", traceback_war=False) + self.pexcept("dir does not take any positional arguments:", traceback_war=False) self.do_help('dir') self.last_result = cmd2.CommandResult('', 'Bad arguments') return -- cgit v1.2.1 From 36c310f9311bc9a48428950a9532934ffc3f45f2 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Tue, 25 Jun 2019 14:05:20 -0400 Subject: Replaced more pexcept uses with perror --- examples/python_scripting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/python_scripting.py') diff --git a/examples/python_scripting.py b/examples/python_scripting.py index f9461fa5..0cbfddff 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -56,7 +56,7 @@ class CmdLineApp(cmd2.Cmd): """ # Expect 1 argument, the directory to change to if not arglist or len(arglist) != 1: - self.pexcept("cd requires exactly 1 argument:", traceback_war=False) + self.perror("cd requires exactly 1 argument:") self.do_help('cd') self.last_result = cmd2.CommandResult('', 'Bad arguments') return @@ -83,7 +83,7 @@ class CmdLineApp(cmd2.Cmd): data = path if err: - self.pexcept(err, traceback_war=False) + self.perror(err) self.last_result = cmd2.CommandResult(out, err, data) # Enable tab completion for cd command @@ -98,7 +98,7 @@ class CmdLineApp(cmd2.Cmd): """List contents of current directory.""" # No arguments for this command if unknown: - self.pexcept("dir does not take any positional arguments:", traceback_war=False) + self.perror("dir does not take any positional arguments:") self.do_help('dir') self.last_result = cmd2.CommandResult('', 'Bad arguments') return -- cgit v1.2.1 From f91ccf2bb28531f9d1dee551314cb091fa57df74 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Thu, 27 Jun 2019 23:54:07 -0400 Subject: Simplified ansi color dictionaries and lookup methods Also: - Updated examples that use color to use cmd2.ansi instead of colorama - Updated tests that use color to use cmd2.ansi instead of colorama - plumbum_colorspy example shows how to override color lookup functions to use a different color library --- examples/python_scripting.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples/python_scripting.py') diff --git a/examples/python_scripting.py b/examples/python_scripting.py index 0cbfddff..3d0a54a9 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -17,9 +17,8 @@ This application and the "scripts/conditional.py" script serve as an example for import argparse import os -from colorama import Fore - import cmd2 +from cmd2 import ansi class CmdLineApp(cmd2.Cmd): @@ -35,7 +34,7 @@ class CmdLineApp(cmd2.Cmd): def _set_prompt(self): """Set prompt so it displays the current working directory.""" self.cwd = os.getcwd() - self.prompt = Fore.CYAN + '{!r} $ '.format(self.cwd) + Fore.RESET + self.prompt = ansi.style('{!r} $ '.format(self.cwd), fg='cyan') def postcmd(self, stop: bool, line: str) -> bool: """Hook method executed just after a command dispatch is finished. -- cgit v1.2.1