File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 1
- ## 0.9.3 (TBD, 2018)
1
+ ## 0.9.3 (July TBD, 2018)
2
+ * Bug Fixes
3
+ * Fixed bug when StatementParser `` __init__() `` was called with `` terminators `` equal to `` None ``
4
+ * Fixed bug when `` Cmd.onecmd() `` was called with a raw `` str ``
2
5
3
6
## 0.9.2 (June 28, 2018)
4
7
* Bug Fixes
Original file line number Diff line number Diff line change @@ -1901,14 +1901,19 @@ def _func_named(self, arg: str) -> str:
1901
1901
result = target
1902
1902
return result
1903
1903
1904
- def onecmd (self , statement : Statement ) -> Optional [bool ]:
1904
+ def onecmd (self , statement : Union [ Statement , str ] ) -> Optional [bool ]:
1905
1905
""" This executes the actual do_* method for a command.
1906
1906
1907
1907
If the command provided doesn't exist, then it executes _default() instead.
1908
1908
1909
- :param statement: Command - a parsed command from the input stream
1909
+ :param statement: Command - intended to be a Statement instance parsed command from the input stream,
1910
+ alternative acceptance of a str is present only for backward compatibility with cmd
1910
1911
:return: a flag indicating whether the interpretation of commands should stop
1911
1912
"""
1913
+ # For backwards compatibility with cmd, allow a str to be passed in
1914
+ if not isinstance (statement , Statement ):
1915
+ statement = self ._complete_statement (statement )
1916
+
1912
1917
funcname = self ._func_named (statement .command )
1913
1918
if not funcname :
1914
1919
self .default (statement )
Original file line number Diff line number Diff line change @@ -1787,3 +1787,18 @@ def test_readline_remove_history_item(base_app):
1787
1787
assert readline .get_current_history_length () == 1
1788
1788
readline .remove_history_item (0 )
1789
1789
assert readline .get_current_history_length () == 0
1790
+
1791
+ def test_onecmd_raw_str_continue (base_app ):
1792
+ line = "help"
1793
+ stop = base_app .onecmd (line )
1794
+ out = base_app .stdout .buffer
1795
+ assert not stop
1796
+ assert out .strip () == BASE_HELP .strip ()
1797
+
1798
+ def test_onecmd_raw_str_quit (base_app ):
1799
+ line = "quit"
1800
+ stop = base_app .onecmd (line )
1801
+ out = base_app .stdout .buffer
1802
+ assert stop
1803
+ assert out == ''
1804
+
You can’t perform that action at this time.
0 commit comments