Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
3842233
Simple ply lexer and tests
kotfu Mar 22, 2018
e9086e1
Add requirement for ply
kotfu Mar 22, 2018
55329a9
Add ply.yacc parser for simple command with args
kotfu Mar 23, 2018
c74e6ed
Rename parse results to match pyparsing variables
kotfu Mar 23, 2018
a6f809c
quoted arguments working
kotfu Mar 30, 2018
b556b21
Merge branch 'master' into ply
kotfu Mar 30, 2018
3cc8efa
hash comments working
kotfu Mar 30, 2018
5c00bce
Added support for C-style comments
kotfu Mar 30, 2018
859b45d
Continuing to struggle with ply
kotfu Apr 3, 2018
2ff92ee
Trying out shlex
kotfu Apr 3, 2018
74fcb09
Merge branch 'master' into ply
kotfu Apr 3, 2018
be85e8c
Comment out broken ply tests
kotfu Apr 3, 2018
dd780ed
Add support for C-style and C++-style comments
kotfu Apr 3, 2018
8ec0a4c
Add support for output redirection
kotfu Apr 9, 2018
0afd9cc
Add support for terminator and suffix
kotfu Apr 9, 2018
4c356e5
Make sure redirectors before the terminator are included in the args,…
kotfu Apr 10, 2018
5924395
Add unicode to todo list
kotfu Apr 10, 2018
f8f65b1
mostly working, but no unicode support…:(
kotfu Apr 12, 2018
a98ff3a
Unicode and almost all redirection operators working
kotfu Apr 17, 2018
5d314d9
Input from file working
kotfu Apr 17, 2018
27e2727
Merge branch 'master' into ply
kotfu Apr 17, 2018
4774401
Extra tests and paste buffer support
kotfu Apr 17, 2018
b45d492
Start multiline work
kotfu Apr 17, 2018
e51b23b
Merge branch 'master' into ply
kotfu Apr 19, 2018
b7cfb13
First multi-line test passes
kotfu Apr 19, 2018
477666d
Merge branch 'master' into ply
kotfu Apr 20, 2018
2350ec2
Move CommandParser class into its own file
kotfu Apr 20, 2018
27b5ab6
A bit of renaming
kotfu Apr 21, 2018
7833901
Merge branch 'master' into ply
kotfu Apr 21, 2018
ece08c3
new shlex based parser grafted into cmd2.py
kotfu Apr 21, 2018
2145115
Delete plyparsing experiment
kotfu Apr 22, 2018
829c36c
refactor Command() to Statement(str)
kotfu Apr 22, 2018
f83154e
args has to be ‘’ not None
kotfu Apr 23, 2018
1c98fe5
Fix default() method
kotfu Apr 23, 2018
7cec2eb
Submenus now call all hooks
kotfu Apr 23, 2018
4f7d0f1
remove old pyparsing unit tests, they have all been duplicated in shlex
kotfu Apr 23, 2018
a735180
Fix default_to_shell unit tests
kotfu Apr 23, 2018
65bf06a
Updates to comments and todo list
kotfu Apr 23, 2018
7ac5918
Shortcut and alias processing added to CommandParser()
kotfu Apr 24, 2018
f47568f
Shortcuts and aliases fully implemented.
kotfu Apr 24, 2018
2534df2
No more importing pyparsing
kotfu Apr 24, 2018
b3d7145
Fix parsing of input redirection and appending output
kotfu Apr 24, 2018
7f7adaf
More work on multiline
kotfu Apr 24, 2018
4411d8d
Multiline support mostly done
kotfu Apr 24, 2018
4cee87b
Fix some old bugs and bad behavior in multiline input
kotfu Apr 24, 2018
c378b1d
Another multiline fix
kotfu Apr 24, 2018
3441d1e
Multiline now working
kotfu Apr 24, 2018
4d2143d
Add todo for implementing input redirection
kotfu Apr 24, 2018
6c48990
Merge branch 'master' into ply
kotfu Apr 24, 2018
8297d4d
Refactoring and code cleanup
kotfu Apr 25, 2018
9170550
Add test for alias expansion on incomplete multiline commands
kotfu Apr 25, 2018
1862ac8
Add type hinting
kotfu Apr 25, 2018
be9a010
Cleanup todo list
kotfu Apr 25, 2018
08c5121
Add todo for #327
kotfu Apr 25, 2018
7aa0e6a
Merge branch 'ply' of https://github.com/python-cmd2/cmd2 into ply
kotfu Apr 25, 2018
b20a516
Remove references to legalChars
kotfu Apr 25, 2018
a3ec4f1
Update todo
kotfu Apr 25, 2018
a343ed1
Todo updates
kotfu Apr 26, 2018
a50c568
Merge branch 'ply' of github.com:python-cmd2/cmd2 into ply
kotfu Apr 26, 2018
05ee395
Remove POSIX_SHLEX and STRIP_QUOTES_FOR_NON_POSIX
kotfu Apr 26, 2018
31352a6
Merge branch 'master' into ply
tleonhardt Apr 26, 2018
739d3f4
First stage of refactoring cmd2.parseline() for tab completion
kotfu Apr 27, 2018
36e57da
Merge branch 'ply' of github.com:python-cmd2/cmd2 into ply
kotfu Apr 27, 2018
a57eaef
No more xdist or forking
kotfu Apr 27, 2018
a550159
Remove references to pytest-xdist and pytest-forked
kotfu Apr 27, 2018
070e46b
Fix broken tox builds with codecov
kotfu Apr 27, 2018
618b891
pytest with —cov fails two unit tests. without —cov they pass :(
kotfu Apr 27, 2018
16bf37b
Add description of comment-matching regex
kotfu Apr 27, 2018
0d4cf47
Fix broken interrupt unit tests
kotfu Apr 27, 2018
62b2d26
Remove unused ‘<‘ from REDIRECTION_CHARS
kotfu Apr 27, 2018
9019944
Merge branch 'master' into ply
tleonhardt Apr 27, 2018
c403222
Fixes for constants being in separate file
tleonhardt Apr 27, 2018
34aa287
Merge branch 'ply' of github.com:python-cmd2/cmd2 into ply
kotfu Apr 27, 2018
8c69e0e
Remove ‘<‘ from REDIRECTION_CHARS, it’s no longer used.
kotfu Apr 27, 2018
e54ea63
Merge branch 'master' into ply
tleonhardt Apr 28, 2018
85a3cc1
Removed pyparsing from setup.py as a dependency
tleonhardt Apr 28, 2018
5c14b38
Cleanup requested changes in pull request
kotfu Apr 29, 2018
fd3512a
Move quotes and redirection_chars from arguments to constants
kotfu Apr 29, 2018
85c63d4
multilineCommand -> multiline_command
kotfu Apr 29, 2018
975818f
_command_and_args switched to static method
kotfu Apr 29, 2018
fbc6d0b
pipeTo -> pipe_to
kotfu Apr 29, 2018
83fd707
outputTo -> output_to
kotfu Apr 29, 2018
c7fa696
Fix incorrect error message
kotfu Apr 29, 2018
00093dd
Remove trailing newline from cmdenvironment()
kotfu Apr 29, 2018
7b2d8a2
multilineCommands -> multiline_commands
kotfu Apr 29, 2018
39e74f6
pylint cleanups
kotfu Apr 29, 2018
1297be2
Really get rid of the inputFrom stuff, including documentation
kotfu Apr 29, 2018
1097de1
Clean up documentation references to pyparsing
kotfu Apr 29, 2018
ce6fab8
More todos
kotfu Apr 29, 2018
3a7e713
Add new unit test
kotfu Apr 29, 2018
efce159
Add test_command_with_quoted_args()
kotfu Apr 29, 2018
eecdc5c
Missed a mutable argument
kotfu Apr 30, 2018
4b903e0
Add some documentation
kotfu Apr 30, 2018
0140cf9
Internal refactoring of parsing and tokenizing code
kotfu Apr 30, 2018
119a6e4
Fix nested alias and shortcut expansion
kotfu Apr 30, 2018
b6b4ba2
remove unused file
kotfu Apr 30, 2018
32363e2
extract strip_quotes() to utils module
kotfu Apr 30, 2018
eab09a8
Updated changelog
kotfu Apr 30, 2018
2bd1c8f
Remove changelog items from todo list
kotfu Apr 30, 2018
dbf4846
Updated setup.py
tleonhardt May 2, 2018
802000b
Ensure args is ‘’ for backwards compatibility with cmd
kotfu May 2, 2018
a55f0b6
Merge branch 'test_merge' into test_ply_merge
anselor May 2, 2018
e8d9525
Merge branch 'master' into ply
anselor May 2, 2018
ad634b2
Add argv to Statement object
kotfu May 3, 2018
9ade8ac
Merge branch 'ply' of https://github.com/python-cmd2/cmd2 into ply
kotfu May 3, 2018
fa94eed
Remove SHLEX_TODO.txt
kotfu May 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
## 0.9.0 (TBD, 2018)
* Bug Fixes
* If self.default_to_shell is true, then redirection and piping are now properly passed to the shell. Previously it was truncated.
* Submenus now call all hooks, it used to just call precmd and postcmd.
* Enhancements
* Automatic completion of ``argparse`` arguments via ``cmd2.argparse_completer.AutoCompleter``
* See the [tab_autocompletion.py](https://github.com/python-cmd2/cmd2/blob/master/examples/tab_autocompletion.py) example for a demonstration of how to use this feature
* ``cmd2`` no longer depends on the ``six`` module
* ``cmd2`` is now a multi-file Python package instead of a single-file module
* New pyscript approach that provides a pythonic interface to commands in the cmd2 application.
* Switch command parsing from pyparsing to custom code which utilizes shlex.
* The object passed to do_* methods has changed. It no longer is the pyparsing object, it's a new Statement object, which is a subclass of ``str``. The statement object has many attributes which give you access to various components of the parsed input. If you were using anything but the string in your do_* methods, this change will require you to update your code.
* ``commentGrammers`` is no longer supported or available. Comments are C-style or python style.
* Input redirection no longer supported. Use the load command instead.
* ``multilineCommand`` attribute is ``now multiline_command``
* ``identchars`` is now ignored. The standardlibrary cmd uses those characters to split the first "word" of the input, but cmd2 hasn't used those for a while, and the new parsing logic parses on whitespace, which has the added benefit of full unicode support, unlike cmd or prior versions of cmd2.
* ``set_posix_shlex`` function and ``POSIX_SHLEX`` variable have been removed. Parsing behavior is now always the more forgiving ``posix=false``.
* ``set_strip_quotes`` function and ``STRIP_QUOTES_FOR_NON_POSIX`` have been removed. Quotes are stripped from arguments when presented as a list (a la ``sys.argv``), and present when arguments are presented as a string (like the string passed to do_*).
* Changes
* ``strip_ansi()`` and ``strip_quotes()`` functions have moved to new utils module
* Several constants moved to new constants module
* Deletions (potentially breaking changes)
* Deleted all ``optparse`` code which had previously been deprecated in release 0.8.0
* The ``options`` decorator no longer exists
Expand Down
29 changes: 6 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ The tables below list all prerequisites along with the minimum required version
| Prerequisite | Minimum Version |
| --------------------------------------------------- | --------------- |
| [Python](https://www.python.org/downloads/) | `3.4` |
| [pyparsing](http://pyparsing.wikispaces.com) | `2.1` |
| [pyperclip](https://github.com/asweigart/pyperclip) | `1.6` |

#### Additional prerequisites to run cmd2 unit tests
Expand All @@ -63,15 +62,13 @@ The tables below list all prerequisites along with the minimum required version
### Optional prerequisites for enhanced unit test features
| Prerequisite | Minimum Version |
| ------------------------------------------- | --------------- |
| [pytest-forked](https://pypi.python.org/pypi/pytest-forked)| `0.2` |
| [pytest-xdist](https://pypi.python.org/pypi/pytest-xdist)| `1.15` |
| [pytest-cov](https://pypi.python.org/pypi/pytest-cov) | `1.8` |

If Python is already installed in your machine, run the following commands to validate the versions:

```shell
python -V
pip freeze | grep pyparsing
pip freeze | grep pyperclip
```

If your versions are lower than the prerequisite versions, you should update.
Expand Down Expand Up @@ -190,16 +187,16 @@ Once you have cmd2 cloned, before you start any cmd2 application, you first need

```bash
# Install cmd2 prerequisites
pip install -U pyparsing pyperclip
pip install -U pyperclip

# Install prerequisites for running cmd2 unit tests
pip install -U pytest

# Install prerequisites for building cmd2 documentation
pip install -U sphinx sphinx-rtd-theme

# Install optional prerequisites for running unit tests in parallel and doing code coverage analysis
pip install -U pytest-xdist pytest-cov pytest-forked
# Install optional prerequisites for doing code coverage analysis
pip install -U pytest-cov
```

For doing cmd2 development, you actually do NOT want to have cmd2 installed as a Python package.
Expand Down Expand Up @@ -259,35 +256,21 @@ py.test

and ensure all tests pass.

If you have the `pytest-xdist` pytest distributed testing plugin installed, then you can use it to
dramatically speed up test execution by running tests in parallel on multiple cores like so:

```shell
py.test -n4
```
where `4` should be replaced by the number of parallel threads you wish to run for testing.

If you have the `pytest-forked` pytest plugin (not avilable on Windows) for running tests in isolated formed processes,
you can speed things up even further:

```shell
py.test -nauto --forked
```

#### Measuring code coverage

Code coverage can be measured as follows:

```shell
py.test -nauto --cov=cmd2 --cov-report=term-missing --cov-report=html --forked
py.test --cov=cmd2 --cov-report=term-missing --cov-report=html
```

Then use your web browser of choice to look at the results which are in `<cmd2>/htmlcov/index.html`.

### Squash Your Commits
When you make a pull request, it is preferable for all of your changes to be in one commit.

If you have made more then one commit, then you will can _squash_ your commits.
If you have made more then one commit, then you can _squash_ your commits.

To do this, see [Squashing Your Commits](http://forum.freecodecamp.com/t/how-to-squash-multiple-commits-into-one-with-git/13231).

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Main Features
- Python scripting of your application with ``pyscript``
- Run shell commands with ``!``
- Pipe command output to shell commands with `|`
- Redirect command output to file with `>`, `>>`; input from file with `<`
- Redirect command output to file with `>`, `>>`
- Bare `>`, `>>` with no filename send output to paste buffer (clipboard)
- `py` enters interactive Python console (opt-in `ipy` for IPython console)
- Option to display long output using a pager with ``cmd2.Cmd.ppaged()``
Expand Down Expand Up @@ -57,7 +57,7 @@ pip install -U cmd2
```

cmd2 works with Python 3.4+ on Windows, macOS, and Linux. It is pure Python code with
the only 3rd-party dependencies being on [pyparsing](http://pyparsing.wikispaces.com), and [pyperclip](https://github.com/asweigart/pyperclip).
the only 3rd-party dependencies being on [colorama](https://github.com/tartley/colorama), and [pyperclip](https://github.com/asweigart/pyperclip).
Windows has an additional dependency on [pyreadline](https://pypi.python.org/pypi/pyreadline). Non-Windows platforms
have an additional dependency on [wcwidth](https://pypi.python.org/pypi/wcwidth). Finally, Python
3.4 has an additional dependency on [contextlib2](https://pypi.python.org/pypi/contextlib2).
Expand Down Expand Up @@ -91,7 +91,7 @@ Instructions for implementing each feature follow.

- Multi-line commands

Any command accepts multi-line input when its name is listed in `Cmd.multilineCommands`.
Any command accepts multi-line input when its name is listed in `Cmd.multiline_commands`.
The program will keep expecting input until a line ends with any of the characters
in `Cmd.terminators` . The default terminators are `;` and `/n` (empty newline).

Expand Down Expand Up @@ -165,7 +165,7 @@ class CmdLineApp(cmd2.Cmd):
MUMBLE_LAST = ['right?']

def __init__(self):
self.multilineCommands = ['orate']
self.multiline_commands = ['orate']
self.maxrepeats = 3

# Add stuff to settable and shortcuts before calling base class initializer
Expand Down
Loading