Releases: python-cmd2/cmd2
Releases · python-cmd2/cmd2
0.9.15 (July 24, 2019)
- Bug Fixes
- Fixed exception caused by tab completing after an invalid subcommand was entered
- Fixed bug where
history -v
was sometimes showing raw and expanded commands when they weren't different - Fixed bug where multiline commands were having leading and ending spaces stripped. This would mess up quoted strings that crossed multiple lines.
- Fixed a bug when appending to the clipboard where contents were in reverse order
- Fixed issue where run_pyscript failed if the script's filename had 2 or more consecutive spaces
- Fixed issue where completer function of disabled command would still run
- Enhancements
- Greatly simplified using argparse-based tab completion. The new interface is a complete overhaul that breaks the previous way of specifying completion and choices functions. See header of argparse_custom.py for more information.
- Enabled tab completion on multiline commands
- Renamed Commands Notice
- The following commands were renamed in the last release and have been removed in this release
load
- replaced byrun_script
_relative_load
- replaced by_relative_run_script
pyscript
- replaced byrun_pyscript
- We apologize for any inconvenience, but the new names are more self-descriptive
- Lots of end users were confused particularly about what exactly
load
should be loading
- Lots of end users were confused particularly about what exactly
- The following commands were renamed in the last release and have been removed in this release
- Breaking Changes
- Restored
cmd2.Cmd.statement_parser
to be a public attribute (no underscore)- Since it can be useful for creating post-parsing hooks
- Completely overhauled the interface for adding tab completion to argparse arguments. See enhancements for more details.
ACArgumentParser
is now calledCmd2ArgumentParser
- Moved
basic_complete
to utils.py - Made optional arguments on the following completer methods keyword-only:
delimiter_complete
,flag_based_complete
,index_based_complete
,path_complete
,shell_cmd_complete
- Renamed history option from
--output-file
to--output_file
- Renamed
matches_sort_key
todefault_sort_key
. This value determines the default sort ordering of string results like alias, command, category, macro, settable, and shortcut names. Unsorted tab-completion results also are sorted with this key. Its default value (ALPHABETICAL_SORT_KEY) performs a case-insensitive alphabetical sort, but it can be changed to a natural sort by setting the value to NATURAL_SORT_KEY. StatementParser
now expects shortcuts to be passed in as dictionary. This eliminates the step of converting the shortcuts dictionary into a tuple before creatingStatementParser
.- Renamed
Cmd.pyscript_name
toCmd.py_bridge_name
- Renamed
Cmd.pystate
toCmd.py_locals
- Renamed
PyscriptBridge
toPyBridge
- Restored
0.9.14 (June 29, 2019)
- Enhancements
- Added support for and testing with Python 3.8, starting with 3.8 beta
- Improved information displayed during transcript testing
- Added
ansi
module with functions and constants to support ANSI escape sequences which are used for things like applying style to text - Added support for applying styles (color, bold, underline) to text via
style()
function inansi
module - Added default styles to ansi.py for printing
success
,warning
. anderror
text. These are the styles used by cmd2 and can be overridden to match the color scheme of your application. - Added
ansi_aware_write()
function toansi
module. This function takes into account the value ofallow_ansi
to determine if ANSI escape sequences should be stripped when not writing to a tty. See documentation for more information on theallow_ansi
setting.
- Breaking Changes
- Python 3.4 reached its end of life on March 18, 2019 and is no longer supported by
cmd2
- If you need to use Python 3.4, you should pin your requirements to use
cmd2
0.9.13
- If you need to use Python 3.4, you should pin your requirements to use
- Made lots of changes to minimize the public API of the
cmd2.Cmd
class- Attributes and methods we do not intend to be public now all begin with an underscore
- We make no API stability guarantees about these internal functions
- Split
perror
into 2 functions:perror
- print a message to sys.stderrpexcept
- print Exception message to sys.stderr. If debug is true, print exception traceback if one exists
- Signature of
poutput
andperror
significantly changed- Removed color parameters
color
,err_color
, andwar_color
frompoutput
andperror
- See the docstrings of these methods or the cmd2 docs for more info on applying styles to output messages
end
argument is now keyword-only and cannot be specified positionallytraceback_war
no longer exists as an argument since it isn't needed now thatperror
andpexcept
exist
- Removed color parameters
- Moved
cmd2.Cmd.colors
to ansi.py and renamed it toallow_ansi
. This is now an application-wide setting. - Renamed the following constants and moved them to ansi.py
COLORS_ALWAYS
-->ANSI_ALWAYS
COLORS_NEVER
-->ANSI_NEVER
COLORS_TERMINAL
-->ANSI_TERMINAL
- Python 3.4 reached its end of life on March 18, 2019 and is no longer supported by
- Renamed Commands Notice
- The following commands have been renamed. The old names will be supported until the next release.
load
-->run_script
_relative_load
-->_relative_run_script
pyscript
-->run_pyscript
- The following commands have been renamed. The old names will be supported until the next release.
0.9.13 (June 14, 2019)
- Bug Fixes
- Fixed issue where the wrong terminator was being appended by
Statement.expanded_command_line()
- Fixed issue where aliases and macros could not contain terminator characters in their values
- History now shows what was typed for macros and not the resolved value by default. This is consistent with the behavior of aliases. Use the
expanded
orverbose
arguments tohistory
to see the resolved value for the macro. - Fixed parsing issue in case where output redirection appears before a pipe. In that case, the pipe was given precedence even though it appeared later in the command.
- Fixed issue where quotes around redirection file paths were being lost in
Statement.expanded_command_line()
- Fixed a bug in how line numbers were calculated for transcript testing
- Fixed issue where
_cmdloop()
suppressed exceptions by returning from within itsfinally
code - Fixed UnsupportedOperation on fileno error when a shell command was one of the commands run while generating a transcript
- Fixed bug where history was displaying expanded multiline commands when -x was not specified
- Fixed issue where the wrong terminator was being appended by
- Enhancements
- Added capability to chain pipe commands and redirect their output (e.g. !ls -l | grep user | wc -l > out.txt)
pyscript
limits a command's stdout capture to the same period that redirection does. Therefore output from a command's postparsing and finalization hooks isn't saved in the StdSim object.StdSim.buffer.write()
now flushes when the wrapped stream uses line buffering and the bytes being written contain a newline or carriage return. This helps whenpyscript
is echoing the output of a shell command since the output will print at the same frequency as when the command is run in a terminal.- ACArgumentParser no longer prints complete help text when a parsing error occurs since long help messages scroll the actual error message off the screen.
- Exceptions occurring in tab completion functions are now printed to stderr before returning control back to readline. This makes debugging a lot easier since readline suppresses these exceptions.
- Added support for custom Namespaces in the argparse decorators. See description of
ns_provider
argument for more information. - Transcript testing now sets the
exit_code
returned fromcmdloop
based on Success/Failure - The history of entered commands previously was saved using the readline persistence mechanism, and only persisted if you had readline installed. Now history is persisted independent of readline; user input from previous invocations of
cmd2
based apps now shows in thehistory
command. - Text scripts now run immediately instead of adding their commands to
cmdqueue
. This allows easy capture of the entire script's output. - Added member to
CommandResult
calledstop
which is the return value ofonecmd_plus_hooks
after it runs the given command line.
- Breaking changes
- Replaced
unquote_redirection_tokens()
withunquote_specific_tokens()
. This was to support the fix that allows terminators in alias and macro values. - Changed
Statement.pipe_to
to a string instead of a list preserve_quotes
is now a keyword-only argument in the argparse decorators- Refactored so that
cmd2.Cmd.cmdloop()
returns theexit_code
instead of a call tosys.exit()
It is now application developer's responsibility to treat the return value fromcmdloop()
accordingly - Only valid commands are persistent in history between invocations of
cmd2
based apps. Previously all user input was persistent in history. If readline is installed, the history available with the up and down arrow keys (readline history) may not match that shown in thehistory
command, becausehistory
only tracks valid input, while readline history captures all input. - History is now persisted in a binary format, not plain text format. Previous history files are destroyed on first launch of a
cmd2
based app of version 0.9.13 or higher. - HistoryItem class is no longer a subclass of
str
. If you are directly accessing the.history
attribute of acmd2
based app, you will need to update your code to use.history.get(1).statement.raw
instead. - Removed internally used
eos
command that was used to keep track of when a text script's commands ended - Removed
cmd2
member called_STOP_AND_EXIT
since it was just a boolean value that should always be True - Removed
cmd2
member called_should_quit
sincePyscriptBridge
now handles this logic - Removed support for
cmd.cmdqueue
allow_cli_args
is now an argument to init instead of acmd2
class member
- Replaced
- Python 3.4 EOL notice
- Python 3.4 reached its end of life on March 18, 2019
- This is the last release of
cmd2
which will support Python 3.4
0.9.12 (April 22, 2019) 🌍
- Bug Fixes
- Fixed a bug in how redirection and piping worked inside
py
orpyscript
commands - Fixed bug in
async_alert
where it didn't account for prompts that contained newline characters - Fixed path completion case when CWD is just a slash. Relative path matches were incorrectly prepended with a slash.
- Fixed a bug in how redirection and piping worked inside
- Enhancements
- Added ability to include command name placeholders in the message printed when trying to run a disabled command.
- See docstring for
disable_command()
ordisable_category()
for more details.
- See docstring for
- Added instance attributes to customize error messages without having to override methods. Theses messages can also be colored.
help_error
- the error that prints when no help information can be founddefault_error
- the error that prints when a non-existent command is run
- The
with_argparser
decorators now add the Statement object created when parsing the command line to theargparse.Namespace
object they pass to thedo_*
methods. It is stored in an attribute called__statement__
. This can be useful if a command function needs to know the command line for things like logging. - Added a
-t
option to theload
command for automatically generating a transcript based on a script file - When in a pyscript, the stdout and stderr streams of shell commands and processes being piped to are now captured and included in the
CommandResult
structure.
- Added ability to include command name placeholders in the message printed when trying to run a disabled command.
- Potentially breaking changes
- The following commands now write to stderr instead of stdout when printing an error. This will make catching errors easier in pyscript.
do_help()
- when no help information can be founddefault()
- in all cases since this is called when an invalid command name is run_report_disabled_command_usage()
- in all cases since this is called when a disabled command is run
- Removed *** from beginning of error messages printed by
do_help()
anddefault()
- Significantly refactored
cmd.Cmd
class so that all class attributes got converted to instance attributes, also:- Added
allow_redirection
,terminators
,multiline_commands
, andshortcuts
as optional arguments tocmd2.Cmd.__init__()
- A few instance attributes were moved inside
StatementParser
and properties were created for accessing them
- Added
self.pipe_proc
is now calledself.cur_pipe_proc_reader
and is aProcReader
class.- Shell commands and commands being piped to while in a pyscript will function as if their output is going to a pipe and not a tty. This was necessary to be able to capture their output.
- Removed
reserved_words
class attribute due to lack of use - Removed
keywords
instance attribute due to lack of use
- The following commands now write to stderr instead of stdout when printing an error. This will make catching errors easier in pyscript.
0.9.11 (March 13, 2019)
- Bug Fixes
- Fixed bug in how history command deals with multiline commands when output to a script
- Fixed a bug when the
with_argument_list
decorator is called with the optionalpreserve_quotes
argument - Fix bug in
perror()
where it would try to print an exception Traceback even if none existed
- Enhancements
- Improvements to the history command
- Simplified the display format and made it more similar to bash
- Added -x, --expanded flag
- output expanded commands instead of entered command (expands aliases, macros, and shortcuts)
- Added -v, --verbose flag
- display history and include expanded commands if they differ from the typed command
- Added support for negative indices
- Added
matches_sort_key
to override the default way tab completion matches are sorted - Added
StdSim.pause_storage
member which when True will causeStdSim
to not save the output sent to it. See documentation forCommandResult
inpyscript_bridge.py
for reasons pausing the storage can be useful. - Added ability to disable/enable individual commands and entire categories of commands. When a command is disabled, it will not show up in the help menu or tab complete. If a user tries to run the command or call help on it, a command-specific message supplied by the developer will be printed. The following commands were added to support this feature.
enable_command()
enable_category()
disable_command()
disable_category()
- Improvements to the history command
- Potentially breaking changes
- Made
cmd2_app
a positional and required argument ofAutoCompleter
since certain functionality now requires that it can't beNone
. AutoCompleter
no longer assumesCompletionItem
results are sorted. Therefore you should follow thecmd2
convention of settingself.matches_sorted
to True before returning the results if you have already sorted theCompletionItem
list. Otherwise it will be sorted usingself.matches_sort_key
.- Removed support for bash completion since this feature had slow performance. Also it relied on
AutoCompleter
which has since developed a dependency oncmd2
methods. - Removed ability to call commands in
pyscript
as if they were functions (e.gapp.help()
) in favor of only supporting onepyscript
interface. This simplifies future maintenance. - No longer supporting C-style comments. Hash (#) is the only valid comment marker.
- No longer supporting comments embedded in a command. Only command line input where the first non-whitespace character is a # will be treated as a comment. This means any # character appearing later in the command will be treated as a literal. The same applies to a # in the middle of a multiline command, even if it is the first character on a line.
- # this is a comment
- this # is not a comment
- Made
0.9.10 (February 22, 2019)
0.9.10 (February 22, 2019)
- Bug Fixes
- Fixed unit test that hangs on Windows
0.9.9 (February 21, 2019)
- Bug Fixes
- Fixed bug where the
set
command was not tab completing from the currentsettable
dictionary.
- Fixed bug where the
- Enhancements
- Changed edit command to use do_shell() instead of calling os.system()
0.9.8 (February 06, 2019)
- Bug Fixes
- Fixed issue with echoing strings in StdSim. Because they were being sent to a binary buffer, line buffering was being ignored.
- Enhancements
- Made quit() and exit() functions available to scripts run with pyscript. This allows those scripts to exit back to the console's prompt instead of exiting the whole application.
0.9.7 (January 08, 2019)
- Bug Fixes
- Fixed bug when user chooses a zero or negative index when calling
Cmd.select()
- Restored behavior where
cmd_echo
always starts as False in a py script. This was broken in 0.9.5.
- Fixed bug when user chooses a zero or negative index when calling
- Enhancements
- cmdloop now only attempts to register a custom signal handler for SIGINT if running in the main thread
- commands run as a result of
default_to_shell
being True now run viado_shell()
and are saved
to history. - Added more tab completion to pyscript command.
- Deletions (potentially breaking changes)
- Deleted
Cmd.colorize()
andCmd._colorcodes
which were deprecated in 0.9.5 - Replaced
dir_exe_only
anddir_only
flags inpath_complete
with optionalpath_filter
function
that is used to filter paths out of completion results. perror()
no longer prepends "ERROR: " to the error message being printed
- Deleted
0.9.6 (October 13, 2018)
- Bug Fixes
- Fixed bug introduced in 0.9.5 caused by backing up and restoring
self.prompt
inpseudo_raw_input
.
As part of this fix, continuation prompts will not be redrawn withasync_update_prompt
orasync_alert
.
- Fixed bug introduced in 0.9.5 caused by backing up and restoring
- Enhancements
- All platforms now depend on wcwidth to assist with asynchronous alerts.
- Macros now accept extra arguments when called. These will be tacked onto the resolved command.
- All cmd2 commands run via
py
now go throughonecmd_plus_hooks
.