Skip to content

Commit 532bb1c

Browse files
authored
Merge branch 'master' into support-load-in-onecmd_plus_hooks
2 parents 6fa589b + 7530674 commit 532bb1c

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.7.8 (TBD, 2017)
2+
3+
* Bug Fixes
4+
* Fixed ``poutput()`` so it can print an integer zero and other **falsy** things
5+
* Enhancements
6+
* Improved documentation for user-settable environment parameters
7+
* Improved documentation for overriding the default supported comment styles
8+
19
## 0.7.7 (August 25, 2017)
210

311
* Bug Fixes
@@ -12,7 +20,7 @@
1220
* The prior behavior removed whitespace before making the comparison, now whitespace must match exactly
1321
* Prior version did not allow regexes with whitespace, new version allows any regex
1422
* Improved display for ``load`` command and input redirection when **echo** is ``True``
15-
23+
1624
## 0.7.6 (August 11, 2017)
1725

1826
* Bug Fixes

cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
else:
9999
BROKEN_PIPE_ERROR = IOError
100100

101-
__version__ = '0.7.7'
101+
__version__ = '0.7.8a'
102102

103103
# Pyparsing enablePackrat() can greatly speed up parsing, but problems have been seen in Python 3 in the past
104104
pyparsing.ParserElement.enablePackrat()

docs/freefeatures.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ before it is passed to a ``do_`` method. By
3636
default, both Python-style and C-style comments
3737
are recognized; you may change this by overriding
3838
``app.commentGrammars`` with a different pyparsing_
39-
grammar.
39+
grammar (see the arg_print_ example for specifically how to to this).
4040

4141
Comments can be useful in :ref:`scripts`, but would
4242
be pointless within an interactive session.
@@ -52,6 +52,7 @@ be pointless within an interactive session.
5252
it was delicious!
5353

5454
.. _pyparsing: http://pyparsing.wikispaces.com/
55+
.. _arg_print: https://github.com/python-cmd2/cmd2/blob/master/examples/arg_print.py
5556

5657
Commands at invocation
5758
======================

examples/arg_print.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
"""A simple example demonstrating the following:
4+
1) How arguments and options get parsed and passed to commands
5+
2) How to change what syntax get parsed as a comment and stripped from the arguments
6+
7+
This is intended to serve as a live demonstration so that developers can experiment with and understand how command
8+
and argument parsing is intended to work.
9+
"""
10+
import pyparsing
11+
import cmd2
12+
from cmd2 import options, make_option
13+
14+
15+
class ArgumentAndOptionPrinter(cmd2.Cmd):
16+
""" Example cmd2 application where we create commands that just print the arguments they are called with."""
17+
18+
def __init__(self):
19+
# Uncomment this line to disable Python-style comments but still allow C-style comments
20+
# self.commentGrammars = pyparsing.Or([pyparsing.cStyleComment])
21+
22+
# Make sure to call this super class __init__ after setting commentGrammars and not before
23+
cmd2.Cmd.__init__(self)
24+
25+
def do_aprint(self, arg):
26+
"""Print the argument string this basic command is called with."""
27+
print('aprint was called with argument: {!r}'.format(arg))
28+
29+
@options([make_option('-p', '--piglatin', action="store_true", help="atinLay"),
30+
make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"),
31+
make_option('-r', '--repeat', type="int", help="output [n] times")], arg_desc='positional_arg_string')
32+
def do_oprint(self, arg, opts=None):
33+
"""Print the options and argument list this options command was called with."""
34+
print('oprint was called with the following\n\toptions: {!r}\n\targuments: {!r}'.format(opts, arg))
35+
36+
37+
if __name__ == '__main__':
38+
app = ArgumentAndOptionPrinter()
39+
app.cmdloop()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
from setuptools import setup
77

8-
VERSION = '0.7.7'
8+
VERSION = '0.7.8a'
99
DESCRIPTION = "cmd2 - a tool for building interactive command line applications in Python"
1010
LONG_DESCRIPTION = """cmd2 is a tool for building interactive command line applications in Python. Its goal is to make
1111
it quick and easy for developers to build feature-rich and user-friendly interactive command line applications. It

tests/test_cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
def test_ver():
27-
assert cmd2.__version__ == '0.7.7'
27+
assert cmd2.__version__ == '0.7.8a'
2828

2929

3030
def test_empty_statement(base_app):

0 commit comments

Comments
 (0)