summaryrefslogtreecommitdiff
path: root/examples/python_scripting.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-29 14:13:55 -0400
committerGitHub <noreply@github.com>2019-06-29 14:13:55 -0400
commitd9ec6f775335133f7b9dc5c33c76eac942243397 (patch)
tree20a2ef40c3e1868accb97201fc0b5ea913cb0878 /examples/python_scripting.py
parentbef07746e33da9def33d814913891384a545a95c (diff)
parent83e418844cbf72250d180d9c529b5ec44c4e7d3d (diff)
downloadcmd2-git-d9ec6f775335133f7b9dc5c33c76eac942243397.tar.gz
Merge pull request #704 from python-cmd2/feature/revisit-color-support
#698 - Revisiting Color Support
Diffstat (limited to 'examples/python_scripting.py')
-rwxr-xr-xexamples/python_scripting.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/python_scripting.py b/examples/python_scripting.py
index c45648bc..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.
@@ -56,7 +55,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.perror("cd requires exactly 1 argument:")
self.do_help('cd')
self.last_result = cmd2.CommandResult('', 'Bad arguments')
return
@@ -83,7 +82,7 @@ class CmdLineApp(cmd2.Cmd):
data = path
if err:
- self.perror(err, traceback_war=False)
+ self.perror(err)
self.last_result = cmd2.CommandResult(out, err, data)
# Enable tab completion for cd command
@@ -98,7 +97,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.perror("dir does not take any positional arguments:")
self.do_help('dir')
self.last_result = cmd2.CommandResult('', 'Bad arguments')
return