Releases: python-cmd2/cmd2
Releases · python-cmd2/cmd2
0.9.22 (December 9, 2019)
- Bug Fixes
- Fixed bug where a redefined
ansi.style_errorwas not being used in allcmd2files
- Fixed bug where a redefined
- Enhancements
- Enabled line buffering when redirecting output to a file
- Added
align_left(),align_center(), andalign_right()to utils.py. All 3 of these functions support ANSI escape sequences and characters with display widths greater than 1. They wrapalign_text()which is also in utils.py.
0.9.21 (November 26, 2019)
- Bug Fixes
- Fixed bug where pipe processes were not being stopped by Ctrl-C
- Added exception handling to account for non-standard Python environments in which readline is not loaded dynamically from a shared library file
- Enhancements
- Added
read_input()function that is used to read from stdin. Unlike the Python built-ininput(), it also has an argument to disable tab completion while input is being entered. - Added capability to override the argument parser class used by cmd2 built-in commands. See override_parser.py example for more details.
- Added
endargument topfeedback()to be consistent with the other print functions likepoutput(). - Added
apply_styletopwarning().
- Added
- Breaking changes
- For consistency between all the print functions:
- Made
endandchopkeyword-only arguments ofppaged() endis always added to message inppaged()
- Made
- For consistency between all the print functions:
0.9.20 (November 12, 2019)
- Bug Fixes
- Fixed bug where setting
use_ipythonto False removed ipy command from the entirecmd2.Cmdclass instead of just the instance being created - Fix bug where cmd2 ran 'stty sane' command when stdin was not a terminal
- Fixed bug where setting
- Enhancements
- Send all startup script paths to run_script. Previously we didn't do this if the file was empty, but that showed no record of the run_script command in history.
- Made it easier for developers to override
editcommand by havingdo_historyno longer calldo_edit. This also removes the need to excludeeditcommand from history list. - It is no longer necessary to set the
progattribute of an argparser with subcommands. cmd2 now automatically sets the prog value of it and all its subparsers so that all usage statements contain the top level command name and not sys.argv[0].
- Breaking changes
- Some constants were moved from cmd2.py to constants.py
- cmd2 command decorators were moved to decorators.py. If you were importing them via cmd2's __init__.py, then there will be no issues.
0.9.19 (October 14, 2019)
- Bug Fixes
- Fixed
ValueErrorexception which could occur when an old format persistent history file is loaded with newcmd2
- Fixed
- Enhancements
- Improved displaying multiline CompletionErrors by indenting all lines
0.9.18 (October 1, 2019)
- Bug Fixes
- Fixed bug introduced in 0.9.17 where help functions for hidden and disabled commands were not being filtered out as help topics
- Enhancements
AutoCompleternow handles argparse's mutually exclusive groups. It will not tab complete flag names or positionals for already completed groups. It also will print an error if you try tab completing a flag's value if the flag belongs to a completed group.AutoCompleternow uses the passed-in parser's help formatter to generate hint text. This gives help and hint text for an argument consistent formatting.
0.9.17 (September 23, 2019)
- Bug Fixes
- Fixed a bug when using WSL when all Windows paths have been removed from $PATH
- Fixed a bug when running a cmd2 application on Linux without Gtk libraries installed
- Enhancements
- No longer treating empty text scripts as an error condition
- Allow dynamically extending a
cmd2.Cmdobject instance with ado_xxxmethod at runtime - Choices/Completer functions can now be passed a dictionary that maps command-line tokens to their argparse argument. This is helpful when one argument determines what is tab completed for another argument. If these functions have an argument called
arg_tokens, then AutoCompleter will automatically pass this dictionary to them. - Added CompletionError class that can be raised during argparse-based tab completion and printed to the user
- Added the following convenience methods
Cmd.in_script()- return whether a text script is runningCmd.in_pyscript()- return whether a pyscript is running
0.9.16 (August 7, 2019)
- Bug Fixes
- Fixed inconsistent parsing/tab completion behavior based on the value of
allow_redirection. This flag is only meant to be a security setting that prevents redirection of stdout and should not alter parsing logic.
- Fixed inconsistent parsing/tab completion behavior based on the value of
- Enhancements
- Raise
TypeErrorif trying to set choices/completions on argparse action that accepts no arguments - Create directory for the persistent history file if it does not already exist
- Added
set_choices_function(),set_choices_method(),set_completer_function(), andset_completer_method()to support cases where this functionality needs to be added to an argparse action outside of the normalparser.add_argument()call.
- Raise
- Breaking Changes
- Aliases and macros can no longer have the same name as a command
0.9.15 (July 24, 2019)
- Bug Fixes
- Fixed exception caused by tab completing after an invalid subcommand was entered
- Fixed bug where
history -vwas 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_scriptpyscript- 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
loadshould 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_parserto 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.
ACArgumentParseris now calledCmd2ArgumentParser- Moved
basic_completeto 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-fileto--output_file - Renamed
matches_sort_keytodefault_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. StatementParsernow 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_nametoCmd.py_bridge_name - Renamed
Cmd.pystatetoCmd.py_locals - Renamed
PyscriptBridgetoPyBridge
- 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
ansimodule 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 inansimodule - Added default styles to ansi.py for printing
success,warning. anderrortext. These are the styles used by cmd2 and can be overridden to match the color scheme of your application. - Added
ansi_aware_write()function toansimodule. This function takes into account the value ofallow_ansito determine if ANSI escape sequences should be stripped when not writing to a tty. See documentation for more information on theallow_ansisetting.
- 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
cmd20.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.Cmdclass- 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
perrorinto 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
poutputandperrorsignificantly changed- Removed color parameters
color,err_color, andwar_colorfrompoutputandperror- See the docstrings of these methods or the cmd2 docs for more info on applying styles to output messages
endargument is now keyword-only and cannot be specified positionallytraceback_warno longer exists as an argument since it isn't needed now thatperrorandpexceptexist
- Removed color parameters
- Moved
cmd2.Cmd.colorsto 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_ALWAYSCOLORS_NEVER-->ANSI_NEVERCOLORS_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_scriptpyscript-->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
expandedorverbosearguments tohistoryto 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 itsfinallycode - 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)
pyscriptlimits 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 whenpyscriptis 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_providerargument for more information. - Transcript testing now sets the
exit_codereturned fromcmdloopbased 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
cmd2based apps now shows in thehistorycommand. - 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
CommandResultcalledstopwhich is the return value ofonecmd_plus_hooksafter 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_toto a string instead of a list preserve_quotesis now a keyword-only argument in the argparse decorators- Refactored so that
cmd2.Cmd.cmdloop()returns theexit_codeinstead 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
cmd2based 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 thehistorycommand, becausehistoryonly 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
cmd2based app of version 0.9.13 or higher. - HistoryItem class is no longer a subclass of
str. If you are directly accessing the.historyattribute of acmd2based app, you will need to update your code to use.history.get(1).statement.rawinstead. - Removed internally used
eoscommand that was used to keep track of when a text script's commands ended - Removed
cmd2member called_STOP_AND_EXITsince it was just a boolean value that should always be True - Removed
cmd2member called_should_quitsincePyscriptBridgenow handles this logic - Removed support for
cmd.cmdqueue allow_cli_argsis now an argument to init instead of acmd2class 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
cmd2which will support Python 3.4