@@ -40,15 +40,16 @@ First we need to create a new ``cmd2`` application. Create a new file
4040 sys.exit(c.cmdloop())
4141
4242We have a new class ``FirstApp `` which is a subclass of
43- :ref: ` api/cmd: cmd2.Cmd `. When we tell python to run our file like this:
43+ :class: ` cmd2.Cmd `. When we tell python to run our file like this:
4444
4545.. code-block :: shell
4646
4747 $ python first_app.py
4848
49- it creates an instance of our class, and calls the ``cmdloop() `` method. This
50- method accepts user input and runs commands based on that input. Because we
51- subclassed ``cmd2.Cmd ``, our new app already has a bunch of features built in.
49+ it creates an instance of our class, and calls the :meth: `~cmd2.Cmd.cmdloop `
50+ method. This method accepts user input and runs commands based on that input.
51+ Because we subclassed :class: `cmd2.Cmd `, our new app already has a bunch of
52+ features built in.
5253
5354Congratulations, you have a working ``cmd2 `` app. You can run it, and then type
5455``quit `` to exit.
@@ -70,11 +71,10 @@ initializer to our class::
7071 self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
7172
7273In that initializer, the first thing to do is to make sure we initialize
73- ``cmd2 ``. That's what the ``super().__init__() `` line does. Then we create an
74- attribute to hold our setting, and then add a description of our setting to the
75- ``settable `` dictionary. If our attribute name isn't in ``settable ``, then it
76- won't be treated as a setting. Now if you run the script, and enter the ``set ``
77- command to see the settings, like this:
74+ ``cmd2 ``. That's what the ``super().__init__() `` line does. Next create an
75+ attribute to hold the setting. Finally, call the :meth: `~cmd2.Cmd.add_settable `
76+ method with a new instance of a :meth: `~cmd2.utils.Settable ` class. Now if you
77+ run the script, and enter the ``set `` command to see the settings, like this:
7878
7979.. code-block :: shell
8080
@@ -131,8 +131,8 @@ There is also a new method called ``do_speak()``. In both cmd_ and ``cmd2``,
131131methods that start with ``do_ `` become new commands, so by defining this method
132132we have created a command called ``speak ``.
133133
134- Note the `` @ cmd2.with_argparser `` decorator on the `` do_speak() `` method. This
135- decorator does 3 useful things for us:
134+ Note the :func: ` ~ cmd2.decorators. with_argparser ` decorator on the
135+ `` do_speak() `` method. This decorator does 3 useful things for us:
136136
1371371. It tells ``cmd2 `` to process all input for the ``speak `` command using the
138138 argparser we defined. If the user input doesn't meet the requirements
@@ -159,8 +159,9 @@ benefits:
1591592. Gracefully handles ``BrokenPipeWarning `` exceptions for redirected output
1601603. Makes the output show up in a :ref: `transcript
161161 <features/transcripts:Transcripts>`
162- 4. Honors the setting to strip embedded ansi sequences (typically used for
163- background and foreground colors)
162+ 4. Honors the setting to :ref: `strip embedded ansi sequences
163+ <features/settings:allow_style>` (typically used for background and
164+ foreground colors)
164165
165166Go run the script again, and try out the ``speak `` command. Try typing ``help
166167speak ``, and you will see a lovely usage message describing the various options
0 commit comments