Skip to content

Commit 414e34e

Browse files
committed
Improved the documentation regarding poutput, particularly with transcripts
The documentation didn't make it very clear that the poutput() method should be used for generating output from cmd2 commands. This PR attempts to fix that. This closes #275.
1 parent 656a774 commit 414e34e

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

docs/transcript.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ A transcript can automatically generated based upon commands previously executed
2626

2727
This is by far the easiest way to generate a transcript.
2828

29+
.. warning::
30+
31+
Make sure you use the **poutput()** method in your ``cmd2`` application for generating command output. This method
32+
of the ``cmd2.Cmd`` class ensure that output is properly redirected when redirecting to a file, pipeing to a shell
33+
command, and when generating a transcript.
34+
2935
Manually
3036
--------
3137
Here's a transcript created from ``python examples/example.py``::

docs/unfreefeatures.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,14 @@ but ``print`` decreases output flexibility). ``cmd2`` applications can use
155155
``self.poutput('output')``, ``self.pfeedback('message')``, and ``self.perror('errmsg')``
156156
instead. These methods have these advantages:
157157

158+
- Handle output redirection to file and/or pipe appropriately
158159
- More concise
159160
- ``.pfeedback()`` destination is controlled by :ref:`quiet` parameter.
160161

162+
.. automethod:: cmd2.Cmd.poutput
163+
.. automethod:: cmd2.Cmd.perror
164+
.. automethod:: cmd2.Cmd.pfeedback
165+
161166

162167
color
163168
=====

0 commit comments

Comments
 (0)