diff options
author | kotfu <kotfu@kotfu.net> | 2019-11-29 16:10:20 -0700 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2019-11-29 16:10:20 -0700 |
commit | 029afe48b09bf32001d830c880fb32ca9defb8ef (patch) | |
tree | 6239e2b2b198444bc65fa1c50bafb2e7042beec7 /cmd2/cmd2.py | |
parent | 965d46bd60557efca3e75cf46c8aa76194c4039b (diff) | |
download | cmd2-git-029afe48b09bf32001d830c880fb32ca9defb8ef.tar.gz |
Show various options for documenting attributes
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 1eeb4212..9f2dd329 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -292,8 +292,8 @@ class Cmd(cmd.Cmd): # The error that prints when a non-existent command is run self.default_error = "{} is not a recognized command, alias, or macro" + """The error message displayed when a non-existent command is run.""" - # If this string is non-empty, then this warning message will print if a broken pipe error occurs while printing self.broken_pipe_warning = '' # Commands that will run at the beginning of the command loop @@ -416,6 +416,20 @@ class Cmd(cmd.Cmd): self.perror('Invalid value: {} (valid values: {}, {}, {})'.format(new_val, ansi.ANSI_TERMINAL, ansi.ANSI_ALWAYS, ansi.ANSI_NEVER)) + @property + def broken_pipe_warning(self) -> str: + """Message to display if a BrokenPipeError is raised while writing output. + + :meth:`~cmd2.cmd2.Cmd.poutput()` catches BrokenPipeError exceptions and + outputs the contents of `broken_pipe_warning`. The default value is an + empty string meaning the BrokenPipeError is silently swallowed. + """ + return self.broken_pipe_error + + @broken_pipe_warning.setter + def broken_pipe_warning(self, new_val: str) -> None: + self.broken_pipe_error = new_val + def _completion_supported(self) -> bool: """Return whether tab completion is supported""" return self.use_rawinput and self.completekey and rl_type != RlType.NONE |