Skip to content

Commit ddd07f9

Browse files
authored
Merge pull request #696 from python-cmd2/script_refactor
Script refactor
2 parents f64f9d5 + 756d8d3 commit ddd07f9

29 files changed

+484
-403
lines changed

CHANGELOG.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,50 @@
99
precedence even though it appeared later in the command.
1010
* Fixed issue where quotes around redirection file paths were being lost in `Statement.expanded_command_line()`
1111
* Fixed a bug in how line numbers were calculated for transcript testing
12+
* Fixed issue where `_cmdloop()` suppressed exceptions by returning from within its `finally` code
13+
* Fixed UnsupportedOperation on fileno error when a shell command was one of the commands run while generating
14+
a transcript
1215
* Enhancements
1316
* Added capability to chain pipe commands and redirect their output (e.g. !ls -l | grep user | wc -l > out.txt)
1417
* `pyscript` limits a command's stdout capture to the same period that redirection does.
15-
Therefore output from a command's postparsing and finalization hooks isn't saved in the StdSim object.
18+
Therefore output from a command's postparsing and finalization hooks isn't saved in the StdSim object.
1619
* `StdSim.buffer.write()` now flushes when the wrapped stream uses line buffering and the bytes being written
17-
contain a newline or carriage return. This helps when `pyscript` is echoing the output of a shell command
18-
since the output will print at the same frequency as when the command is run in a terminal.
20+
contain a newline or carriage return. This helps when `pyscript` is echoing the output of a shell command
21+
since the output will print at the same frequency as when the command is run in a terminal.
1922
* **ACArgumentParser** no longer prints complete help text when a parsing error occurs since long help messages
20-
scroll the actual error message off the screen.
23+
scroll the actual error message off the screen.
2124
* Exceptions occurring in tab completion functions are now printed to stderr before returning control back to
2225
readline. This makes debugging a lot easier since readline suppresses these exceptions.
2326
* Added support for custom Namespaces in the argparse decorators. See description of `ns_provider` argument
2427
for more information.
2528
* Transcript testing now sets the `exit_code` returned from `cmdloop` based on Success/Failure
2629
* The history of entered commands previously was saved using the readline persistence mechanism,
27-
and only persisted if you had readline installed. Now history is persisted independent of readline; user
28-
input from previous invocations of `cmd2` based apps now shows in the `history` command.
29-
30+
and only persisted if you had readline installed. Now history is persisted independent of readline; user
31+
input from previous invocations of `cmd2` based apps now shows in the `history` command.
32+
* Text scripts now run immediately instead of adding their commands to `cmdqueue`. This allows easy capture of
33+
the entire script's output.
34+
* Added member to `CommandResult` called `stop` which is the return value of `onecmd_plus_hooks` after it runs
35+
the given command line.
3036
* Breaking changes
3137
* Replaced `unquote_redirection_tokens()` with `unquote_specific_tokens()`. This was to support the fix
32-
that allows terminators in alias and macro values.
38+
that allows terminators in alias and macro values.
3339
* Changed `Statement.pipe_to` to a string instead of a list
3440
* `preserve_quotes` is now a keyword-only argument in the argparse decorators
3541
* Refactored so that `cmd2.Cmd.cmdloop()` returns the `exit_code` instead of a call to `sys.exit()`
36-
It is now application developer's responsibility to treat the return value from `cmdloop()` accordingly
42+
It is now application developer's responsibility to treat the return value from `cmdloop()` accordingly
3743
* Only valid commands are persistent in history between invocations of `cmd2` based apps. Previously
38-
all user input was persistent in history. If readline is installed, the history available with the up and
39-
down arrow keys (readline history) may not match that shown in the `history` command, because `history`
40-
only tracks valid input, while readline history captures all input.
44+
all user input was persistent in history. If readline is installed, the history available with the up and
45+
down arrow keys (readline history) may not match that shown in the `history` command, because `history`
46+
only tracks valid input, while readline history captures all input.
4147
* History is now persisted in a binary format, not plain text format. Previous history files are destroyed
42-
on first launch of a `cmd2` based app of version 0.9.13 or higher.
48+
on first launch of a `cmd2` based app of version 0.9.13 or higher.
4349
* HistoryItem class is no longer a subclass of `str`. If you are directly accessing the `.history` attribute
44-
of a `cmd2` based app, you will need to update your code to use `.history.get(1).statement.raw` instead.
50+
of a `cmd2` based app, you will need to update your code to use `.history.get(1).statement.raw` instead.
51+
* Removed internally used `eos` command that was used to keep track of when a text script's commands ended
52+
* Removed `cmd2` member called `_STOP_AND_EXIT` since it was just a boolean value that should always be True
53+
* Removed `cmd2` member called `_should_quit` since `PyscriptBridge` now handles this logic
54+
* Removed support for `cmd.cmdqueue`
55+
* `allow_cli_args` is now an argument to __init__ instead of a `cmd2` class member
4556
* **Python 3.4 EOL notice**
4657
* Python 3.4 reached its [end of life](https://www.python.org/dev/peps/pep-0429/) on March 18, 2019
4758
* This is the last release of `cmd2` which will support Python 3.4

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2008-2016 Catherine Devlin and others
3+
Copyright (c) 2008-2019 Catherine Devlin and others
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

cmd2/argparse_completer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def my_completer(text: str, line: str, begidx: int, endidx:int, extra_param: str
5555
The subcommand group dictionary maps subcommand names to tuple(arg_choices, subcmd_args_lookup)
5656
5757
For more details of this more complex approach see tab_autocompletion.py in the examples
58-
59-
Copyright 2018 Eric Lin <anselor@gmail.com>
60-
Released under MIT license, see LICENSE file
6158
"""
6259

6360
import argparse

0 commit comments

Comments
 (0)