diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-03-04 18:44:00 -0500 |
|---|---|---|
| committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-03-04 18:44:00 -0500 |
| commit | 57ce8cc24a44a035ae1830ba6e7d5faf9f4bf95f (patch) | |
| tree | 582673ffc8e5c26d1026a05a8dfb34cd998ce1b6 /docs | |
| parent | 51ed730e452caa646adc1c1e9147aa42813cda91 (diff) | |
| download | cmd2-git-57ce8cc24a44a035ae1830ba6e7d5faf9f4bf95f.tar.gz | |
Added info to CHANGES.rst on what bugs have been fixed so far this release.
Fixed a bug where the allow_cli_args attribute wasn't properly preventing OptParse from prasing the args looking for "-t" or "--test" for transcript testing.
Added an example of using Argparse with cmd2.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/freefeatures.rst | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 2c41c213..0f6a0e84 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -63,6 +63,18 @@ quotation marks if it is more than a one-word command. Gracie cat@eee:~/proj/cmd2/example$ +.. note:: + + if you wish to disable cmd2's consumption of command-line arguments, you can do so by setting the ``allow_cli_args`` + attribute of your ``cmd2.Cmd`` class instance to ``False``. This would be useful, for example, if you wish to use + someting like Argparse_ to parse the overall command line arguments for your application:: + + from cmd2 import Cmd + class App(Cmd): + def __init__(self): + self.allow_cli_args = False + +.. _Argparse: https://docs.python.org/3/library/argparse.html Output redirection ================== @@ -242,3 +254,17 @@ Regular expressions can be embedded in the transcript inside paired ``/`` slashes. These regular expressions should not include any whitespace expressions. +.. note:: + + If you have set ``allow_cli_args`` to False in order to disable parsing of command line arguments at invocaiton, + then the use of ``-t`` or ``--test`` to run transcript testing is automatically disabled. In this case, you can + alternatively provide a value for the optional ``transcript_files`` when constructing the instance of your + ``cmd2.Cmd`` derived class in order to cause a transcript test to run:: + + from cmd2 import Cmd + class App(Cmd): + # customized attributes and methods here + + if __name__ == '__main__': + app = App(transcript_files='exampleSession.txt') + app.cmdloop() |
