You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- change the walk through from example.py to a new first_app.py (based on example.py)
- remove the feature tour section, we’ll use the first application to demo the key features
this code to ``example.py``, so that the ``speak_parser`` attribute and the
94
+
this code to ``first_app.py``, so that the ``speak_parser`` attribute and the
97
95
``do_speak()`` method are part of the ``CmdLineApp()`` class::
98
96
99
97
speak_parser = argparse.ArgumentParser()
@@ -124,8 +122,8 @@ Up at the top of the script, you'll also need to add::
124
122
There's a bit to unpack here, so let's walk through it. We created
125
123
``speak_parser``, which uses the `argparse
126
124
<https://docs.python.org/3/library/argparse.html>`_ module from the Python
127
-
standard library to parse command line input from a user. There is nothing thus far
128
-
that is specific to ``cmd2``.
125
+
standard library to parse command line input from a user. There is nothing thus
126
+
far that is specific to ``cmd2``.
129
127
130
128
There is also a new method called ``do_speak()``. In both cmd_ and ``cmd2``,
131
129
methods that start with ``do_`` become new commands, so by defining this method
@@ -261,18 +259,20 @@ History
261
259
``cmd2`` tracks the history of the commands that users enter. As a developer,
262
260
you don't need to do anything to enable this functionality, you get it for free.
263
261
If you want the history of commands to persist between invocations of your
264
-
application, you'll need to do a little work. The
265
-
:ref:`features/history:Command History` page has all the details.
262
+
application, you'll need to do a little work. The:ref:`features/history:Command
263
+
History` page has all the details.
266
264
267
265
Users can access command history using two methods:
268
266
269
-
- the `readline <https://docs.python.org/3/library/readline.html>`_ library which provides a python interface to the `GNU readline library <https://tiswww.case.edu/php/chet/readline/rltop.html>`_.
267
+
- the `readline <https://docs.python.org/3/library/readline.html>`_ library
268
+
which provides a python interface to the `GNU readline library
- the ``history`` command which is built-in to ``cmd2``
271
271
272
-
From the prompt in a ``cmd2``-based application, you can press ``<CNTL>-p`` to
273
-
move to the previously entered command, and ``<CNTL>-n`` to move to the next
274
-
command. You can also search through the command history usint ``<CNTL>-r``. The
275
-
`GNU Readline User Manual
272
+
From the prompt in a ``cmd2``-based application, you can press ``Control-p`` to
273
+
move to the previously entered command, and ``Control-n`` to move to the next
274
+
command. You can also search through the command history using ``Control-r``.
275
+
The `GNU Readline User Manual
276
276
<https://tiswww.case.edu/php/chet/readline/rluserman.html>`_ has all the
277
277
details, including all the available commands, and instructions for customizing
278
278
the key bindings.
@@ -286,15 +286,17 @@ With the selected commands, users can:
286
286
- save the commands to a file
287
287
- run the commands, saving both the commands and their output to a file
288
288
289
-
Learn more about the ``history`` command by typing ``history -h`` at any ``cmd2`` input prompt, or by exploring :ref:`Command History For Users <features/history:For Users>`.
289
+
Learn more about the ``history`` command by typing ``history -h`` at any
290
+
``cmd2`` input prompt, or by exploring :ref:`Command History For Users
291
+
<features/history:For Users>`.
290
292
291
293
292
294
Conclusion
293
295
----------
294
296
295
-
You've just created a simple, but functional command line application. With minimal work
296
-
on your part, the application leverages many robust features of ``cmd2``. To learn more
297
-
you can:
297
+
You've just created a simple, but functional command line application. With
298
+
minimal work on your part, the application leverages many robust features of
299
+
``cmd2``. To learn more you can:
298
300
299
301
- Dive into all of the :doc:`../features/index` that ``cmd2`` provides
0 commit comments