summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md7
-rw-r--r--cmd2/ansi.py2
-rw-r--r--cmd2/argparse_custom.py2
-rw-r--r--cmd2/cmd2.py26
4 files changed, 22 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index db23d03d..0c423836 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,9 @@
## 0.9.22 (TBD, 2019)
* Bug Fixes
- * Fixed bug where a redefined `ansi.style_error` was not being used in all `cmd2` files
+ * Fixed bug where a redefined `ansi.style_error` was not being used in all `cmd2` files
+* Other
+ * Removed `bold=True` from `ansi.style_success` because it was difficult for red-greed colorblind users to
+ distinguish that color from the `ansi.style_warning` color in certain terminals.
## 0.9.21 (November 26, 2019)
* Bug Fixes
@@ -488,7 +491,7 @@
* ``cmd2`` now supports Python 3.4+
* Known Issues
* Some developers have noted very slow performance when importing the ``cmd2`` module. The issue
- it intermittant, and investigation of the root cause is ongoing.
+ it intermittent, and investigation of the root cause is ongoing.
## 0.8.6 (May 27, 2018)
* Bug Fixes
diff --git a/cmd2/ansi.py b/cmd2/ansi.py
index db828af4..86161ac2 100644
--- a/cmd2/ansi.py
+++ b/cmd2/ansi.py
@@ -184,7 +184,7 @@ def style(text: Any, *, fg: str = '', bg: str = '', bold: bool = False, underlin
# Default styles for printing strings of various types.
# These can be altered to suit an application's needs and only need to be a
# function with the following structure: func(str) -> str
-style_success = functools.partial(style, fg='green', bold=True)
+style_success = functools.partial(style, fg='green')
"""Partial function supplying arguments to style() to generate bold green text"""
style_warning = functools.partial(style, fg='bright_yellow')
diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py
index cfe9ea5e..51c3375e 100644
--- a/cmd2/argparse_custom.py
+++ b/cmd2/argparse_custom.py
@@ -95,7 +95,7 @@ Tab Completion:
as dynamic. Therefore it is up to the developer to validate if the user has typed an acceptable value for these
arguments.
- The following functions exist in cases where you may want to manually a add choice-providing function/method to
+ The following functions exist in cases where you may want to manually add a choice-providing function/method to
an existing argparse action. For instance, in __init__() of a custom action class.
set_choices_function(action, func)
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index c5b058a0..b025043e 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -455,7 +455,7 @@ class Cmd(cmd.Cmd):
"""
return ansi.strip_ansi(self.prompt)
- def poutput(self, msg: Any, *, end: str = '\n') -> None:
+ def poutput(self, msg: Any = '', *, end: str = '\n') -> None:
"""Print message to self.stdout and appends a newline by default
Also handles BrokenPipeError exceptions for when a commands's output has
@@ -476,8 +476,8 @@ class Cmd(cmd.Cmd):
if self.broken_pipe_warning:
sys.stderr.write(self.broken_pipe_warning)
- @staticmethod
- def perror(msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
+ # noinspection PyMethodMayBeStatic
+ def perror(self, msg: Any = '', *, end: str = '\n', apply_style: bool = True) -> None:
"""Print message to sys.stderr
:param msg: message to print (anything convertible to a str with '{}'.format() is OK)
@@ -491,8 +491,8 @@ class Cmd(cmd.Cmd):
final_msg = "{}".format(msg)
ansi.ansi_aware_write(sys.stderr, final_msg + end)
- def pwarning(self, msg: Any, *, end: str = '\n', apply_style: bool = True) -> None:
- """Like perror, but applies ansi.style_warning by default
+ def pwarning(self, msg: Any = '', *, end: str = '\n', apply_style: bool = True) -> None:
+ """Wraps perror, but applies ansi.style_warning by default
:param msg: message to print (anything convertible to a str with '{}'.format() is OK)
:param end: string appended after the end of the message, default a newline
@@ -1424,7 +1424,7 @@ class Cmd(cmd.Cmd):
except Exception as e:
# Insert a newline so the exception doesn't print in the middle of the command line being tab completed
- self.perror('\n', end='')
+ self.perror()
self.pexcept(e)
return None
@@ -2741,7 +2741,8 @@ class Cmd(cmd.Cmd):
command = ''
self.stdout.write("\n")
- @with_argparser(DEFAULT_ARGUMENT_PARSER(description="List available shortcuts"))
+ shortcuts_parser = DEFAULT_ARGUMENT_PARSER(description="List available shortcuts")
+ @with_argparser(shortcuts_parser)
def do_shortcuts(self, _: argparse.Namespace) -> None:
"""List available shortcuts"""
# Sort the shortcut tuples by name
@@ -2749,13 +2750,15 @@ class Cmd(cmd.Cmd):
result = "\n".join('{}: {}'.format(sc[0], sc[1]) for sc in sorted_shortcuts)
self.poutput("Shortcuts for other commands:\n{}".format(result))
- @with_argparser(DEFAULT_ARGUMENT_PARSER(epilog=INTERNAL_COMMAND_EPILOG))
+ eof_parser = DEFAULT_ARGUMENT_PARSER(description="Called when <Ctrl>-D is pressed", epilog=INTERNAL_COMMAND_EPILOG)
+ @with_argparser(eof_parser)
def do_eof(self, _: argparse.Namespace) -> bool:
"""Called when <Ctrl>-D is pressed"""
# Return True to stop the command loop
return True
- @with_argparser(DEFAULT_ARGUMENT_PARSER(description="Exit this application"))
+ quit_parser = DEFAULT_ARGUMENT_PARSER(description="Exit this application")
+ @with_argparser(quit_parser)
def do_quit(self, _: argparse.Namespace) -> bool:
"""Exit this application"""
# Return True to stop the command loop
@@ -2794,7 +2797,7 @@ class Cmd(cmd.Cmd):
response = self.read_input(prompt)
except EOFError:
response = ''
- self.poutput('\n', end='')
+ self.poutput()
except KeyboardInterrupt as ex:
self.poutput('^C')
raise ex
@@ -3235,7 +3238,8 @@ class Cmd(cmd.Cmd):
# Only include the do_ipy() method if IPython is available on the system
if ipython_available: # pragma: no cover
- @with_argparser(DEFAULT_ARGUMENT_PARSER(description="Enter an interactive IPython shell"))
+ ipython_parser = DEFAULT_ARGUMENT_PARSER(description="Enter an interactive IPython shell")
+ @with_argparser(ipython_parser)
def do_ipy(self, _: argparse.Namespace) -> None:
"""Enter an interactive IPython shell"""
from .py_bridge import PyBridge