<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-packages/cmd2-git.git/tests/test_argparse.py, branch 0.8.0</title>
<subtitle>github.com: python-cmd2/cmd2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/'/>
<entry>
<title>help command temporarily redirects sys.stdout and sys.stderr to self.stdout for argparse commands</title>
<updated>2018-01-22T05:08:27+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-22T05:08:27+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=f28c10a50535f753419bd2120ac6cb0bea9f56e2'/>
<id>f28c10a50535f753419bd2120ac6cb0bea9f56e2</id>
<content type='text'>
In order to make "help" behave more consistently for decorated and undecorated commands, argparse output is temporarily redirected to self.stdout.  So doing "help history" is similar to "help load".

However, when using the "-h" with argparse commands without using the "help" command, the output from argparse isn't redirected to self.stdout.  Fixing this would be rather difficult and would essentially involve creating a pyparsing rule to detect it at the parser level.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In order to make "help" behave more consistently for decorated and undecorated commands, argparse output is temporarily redirected to self.stdout.  So doing "help history" is similar to "help load".

However, when using the "-h" with argparse commands without using the "help" command, the output from argparse isn't redirected to self.stdout.  Fixing this would be rather difficult and would essentially involve creating a pyparsing rule to detect it at the parser level.
</pre>
</div>
</content>
</entry>
<entry>
<title>Renamed @with_argument_parser decorator to @with_argparser</title>
<updated>2018-01-22T03:24:09+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-22T03:24:09+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=c9f7c012bda012b4df7a8c5e853bd5d3e6d99b1b'/>
<id>c9f7c012bda012b4df7a8c5e853bd5d3e6d99b1b</id>
<content type='text'>
Also:
- Reanamed foo and bar subcommand methods to base_foo and base_bar
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also:
- Reanamed foo and bar subcommand methods to base_foo and base_bar
</pre>
</div>
</content>
</entry>
<entry>
<title>Added unit tests for sub-commands</title>
<updated>2018-01-20T21:48:52+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-20T21:48:52+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=5550ab73a91d2834e6bda72eb3889998ad59be51'/>
<id>5550ab73a91d2834e6bda72eb3889998ad59be51</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixed unit tests</title>
<updated>2018-01-20T17:59:39+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-20T17:59:39+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=4046a6968405dce820168913dbfe3690c446dac9'/>
<id>4046a6968405dce820168913dbfe3690c446dac9</id>
<content type='text'>
Updated unit tests due to changes in how help is output for commands decorated with an argparse ArgumentParser.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Updated unit tests due to changes in how help is output for commands decorated with an argparse ArgumentParser.
</pre>
</div>
</content>
</entry>
<entry>
<title>Simplified a few argparse examples and fixed some incorrect documentation</title>
<updated>2018-01-18T02:43:20+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-18T02:43:20+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=03f15696076b04a2881562a0429a435e61ffd92c'/>
<id>03f15696076b04a2881562a0429a435e61ffd92c</id>
<content type='text'>
I eliminated a few "narg=1" configurations so that a single str value is returned instead of a List[str].

I also reworded some documentation which was no longer correct after the last commit which made "history command" have the same help text as "command -h" when using one of the two argparse decorators.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I eliminated a few "narg=1" configurations so that a single str value is returned instead of a List[str].

I also reworded some documentation which was no longer correct after the last commit which made "history command" have the same help text as "command -h" when using one of the two argparse decorators.
</pre>
</div>
</content>
</entry>
<entry>
<title>Improved how new argparse-based decorators provide help</title>
<updated>2018-01-17T18:48:13+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-17T18:48:13+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=b034f6d2de92a784853ddeef4e51b26148056691'/>
<id>b034f6d2de92a784853ddeef4e51b26148056691</id>
<content type='text'>
Now "help command_name" and "command_name -h" provide exactly the same text.

The function docstring for the "do_*" command sets and overrides the ArgumentParser "description" if the docstring is not empty.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now "help command_name" and "command_name -h" provide exactly the same text.

The function docstring for the "do_*" command sets and overrides the ArgumentParser "description" if the docstring is not empty.
</pre>
</div>
</content>
</entry>
<entry>
<title>Added a unit test</title>
<updated>2018-01-15T18:36:29+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-15T18:36:29+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=38989c8d406020d300801331f86255865f133561'/>
<id>38989c8d406020d300801331f86255865f133561</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Renamed new decorator to @with_argparser_and_unknown_args to make it more descriptive</title>
<updated>2018-01-15T17:38:48+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-15T17:38:48+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=1f18c942fc3babf3c2183fdc2331d405d6810dc8'/>
<id>1f18c942fc3babf3c2183fdc2331d405d6810dc8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Changed @with_argument_parser to only pass single argument to commands</title>
<updated>2018-01-15T17:11:12+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-15T17:11:12+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=eee2d621abfb3d6455570b540069a4853a68f8c6'/>
<id>eee2d621abfb3d6455570b540069a4853a68f8c6</id>
<content type='text'>
Also added another @with_argparser_and_list decorator that uses argparse.parse_known_args to pass two arguments to a command:  both the argparse output and a list of unknown/unmatched args.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also added another @with_argparser_and_list decorator that uses argparse.parse_known_args to pass two arguments to a command:  both the argparse output and a list of unknown/unmatched args.
</pre>
</div>
</content>
</entry>
<entry>
<title>Made a couple cleanup changes</title>
<updated>2018-01-15T06:34:50+00:00</updated>
<author>
<name>Todd Leonhardt</name>
<email>todd.leonhardt@gmail.com</email>
</author>
<published>2018-01-15T06:34:50+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/cmd2-git.git/commit/?id=141d95194b30d959f6c21f4546100551c442b13d'/>
<id>141d95194b30d959f6c21f4546100551c442b13d</id>
<content type='text'>
1) cmd2 no longer imports make_option from optparse
- test files and examples now import this directly
- this helps emphasize that this old optparse methodology of adding options to commands is deprecated

2) All argparsers have been given custom names instead of just "argparser"
- this helps with readability and maintainability, especially with IDE renaming and such
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
1) cmd2 no longer imports make_option from optparse
- test files and examples now import this directly
- this helps emphasize that this old optparse methodology of adding options to commands is deprecated

2) All argparsers have been given custom names instead of just "argparser"
- this helps with readability and maintainability, especially with IDE renaming and such
</pre>
</div>
</content>
</entry>
</feed>
