summaryrefslogtreecommitdiff
path: root/cmd2/__init__.py
Commit message (Collapse)AuthorAgeFilesLines
* More mypy validation changes. cmd2.py is nearly fully mypy compliant now.Eric Lin2021-04-021-3/+5
|
* MyPy strict checking doesn't allow implicit exports. Must explicitly export ↵Eric Lin2021-04-021-0/+41
| | | | in __init__.py
* Merge branch 'master' into blackTodd Leonhardt2021-02-191-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # cmd2/__init__.py # cmd2/argparse_completer.py # cmd2/argparse_custom.py # cmd2/cmd2.py # cmd2/decorators.py # cmd2/exceptions.py # cmd2/utils.py # examples/arg_decorators.py # examples/argparse_completion.py # examples/modular_commands_main.py # tests/test_argparse_completer.py # tests/test_argparse_custom.py # tests/test_cmd2.py # tests/test_completion.py # tests/test_history.py
| * Removed with_argparser_and_unknown_args since it was deprecated in 1.3.0.Kevin Van Brunt2021-01-221-2/+1
| |
| * Moved two classes from cmd2.py to utils.py.Kevin Van Brunt2020-09-091-2/+2
| |
| * Refactored ArgparseCompleter to support custom completionKevin Van Brunt2020-09-011-1/+1
| |
| * Merge branch 'master' into 2.0Kevin Van Brunt2020-08-271-1/+1
| |\
| * | Replaced choices_function / choices_method with choices_provider.Kevin Van Brunt2020-08-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced completer_function / completer_method with completer. ArgparseCompleter now always passes cmd2.Cmd or CommandSet instance as the self argument to choices_provider and completer functions. Moved basic_complete from utils into cmd2.Cmd class. Moved CompletionError to exceptions.py
* | | Add black for automatic code formatTodd Leonhardt2021-01-311-2/+3
| |/ |/|
* | The functions cmd2 adds to Namespaces (get_statement() and get_handler()) ↵Kevin Van Brunt2020-08-261-1/+1
|/ | | | | | | are now Cmd2AttributeWrapper objects named cmd2_statement and cmd2_handler. This makes it easy to filter out which attributes in an argparse.Namespace were added by cmd2.
* Verify that a completer function is defined in a CommandSet beforeEric Lin2020-08-061-2/+3
| | | | | | | | | | passing it a CommandSet instance. Search for a CommandSet instance that matches the completer's parent class type.` Resolves Issue #967 Renamed isolated_tests directory to tests_isolated for better visual grouping. Added some exception documentation
* Adds support for injectable subcommands as part of CommandSetEric Lin2020-08-041-1/+1
| | | | | | load/unload. Updated examples and documentation to include discussion of injectable sub-commands.
* Removed support for functions outside of CommandSetsEric Lin2020-08-041-1/+1
|
* Some minor cleanup of how imports work. Fixed issue with help documentation ↵Eric Lin2020-08-041-0/+1
| | | | | | for CommandSet commands. Issue #943
* Added type annotations for fields in cmd2.Cmd.Eric Lin2020-07-211-1/+2
| | | | | | | Cleaned up docstring in external test plugin Updated some initialization to match new approach for version info discovery. Tagged some IDE-only lines as no-cover Adds plugin coverage reporting.
* replace pkg_resources with importlib.metadataDoug Hellmann2020-07-121-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Importing pkg_resources has a side-effect of scanning every installed distribution on sys.path to load the metadata, especially the entry points defined in the packages. This can have a significant launch-time cost for command line applications when there are a lot of distributions to scan. Since cmd2 is only using pkg_resources to find the version of the installed package, pkg_resources can be replaced with importlib.metadata. The implementation in the new library is significantly faster because it goes immediately to the metadata file for the requested distribution, instead of scanning all of them. There are also no import-time side-effects. importlib.metadata is a new standard library module starting with python 3.8. For earlier versions, a compatible library has been released to PyPI as 'importlib_metadata'. This change adds the new dependency with a qualifier so that it is only applied to older versions of python, and then updates the places that were importing pkg_resources to look for the different versions of the new library instead. The documentation configuration is changed to import cmd2 itself to get its version, since the package has to be installed for the metadata to be available anyway. Signed-off-by: Doug Hellmann <doug@doughellmann.com>
* Added SkipPostcommandHooks exception and made Cmd2ArgparseError inherit from it.Kevin Van Brunt2020-05-071-0/+1
| | | | Both exception classes have been added to the public API.
* Moved categorize() to utils.py and made set_parser_prog() non-publicKevin Van Brunt2020-02-201-2/+2
|
* Moved custom cmd2 exceptions to a separate file and removed them from public APITodd Leonhardt2020-02-181-1/+1
|
* Made CompletionError exception available to non-argparse tab completionKevin Van Brunt2020-02-171-2/+2
|
* Added convenience `ansi.fg` and `ansi.bg` enums of foreground and background ↵Todd Leonhardt2020-02-061-1/+1
| | | | | | colors which style() can now optionally use This is to make it easier to autocomplete color names in an IDE
* Added cmd2.utils.Settable to the cmd2 namespace and updated examples and docsTodd Leonhardt2020-02-041-0/+1
|
* Added capability to override the argument parser class used by cmd2 built-in ↵Kevin Van Brunt2019-11-191-1/+11
| | | | commands
* Moving a bit of code around to shrink cmd2.pyKevin Van Brunt2019-10-311-3/+4
| | | | | This includes moving cmd2 decorators into a new file called decorators.py Moved some constants from cmd2.py to constants.py
* Added CompletionError exception classKevin Van Brunt2019-09-201-1/+1
|
* Renamed PyscriptBridge to PyBridgeKevin Van Brunt2019-07-201-1/+1
|
* Renamed ArgParser to Cmd2ArgumentParser to make it clear it's a derived ↵Kevin Van Brunt2019-07-181-1/+1
| | | | | | class of argparse.ArgumentParser when developers read the code in cmd2.py.
* Renamed Cmd2ArgParser to ArgParserKevin Van Brunt2019-07-121-1/+1
|
* Moved all custom argparse classes intended for normal development to ↵Kevin Van Brunt2019-07-071-0/+1
| | | | | | | argparse_custom.py. Lazy loading AutoCompleter in cmd2 instance methods to allow argparse_completer.py to import cmd2.Cmd class. This Architecture makes more sense because AutoCompleter depends on cmd2.Cmd.
* Added import of ansi.style directly into cmd2 namespace in __init__.pyTodd Leonhardt2019-06-291-0/+1
| | | | | Also: - Fixed an example in README which was using print() instead of self.poutput()
* Fixed a bunch of examples which were broken due to moving DEFAULT_SHORTCUTS ↵Todd Leonhardt2019-06-161-0/+1
| | | | from cmd2.py to constants.py
* Fix flake8 issuesTodd Leonhardt2018-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | This commit contains a very large number of trivial changes in order to fix flake8 errors and warnings. Predominantly these are whitespace changes. Additionally, the build for Python 3.7 on TravisCI has been tweaked to fail if there are any flake8 errors using the following commandline: * flake8 . --count --ignore=E252 --max-complexity=31 --max-line-length=127 --show-source --statistics NOTE: In the future the max cyclomatic complexity should be lowered, but some improvements need to be made first. One flake8 error is being ignored entirely: * E252 missing whitespace around parameter equals * ignored because it doesn't correctly deal with default argument values after a type hint A few flake8 errors are being selectively ignored in certain files: * C901 fuction is too complex * ignored in argparse_completer.py because the complex code is an override of argparse complexity * E302 expected 2 blank lines after ... * ignored in all unit test files for convenience * F401 module imported but unused * ignored in cmd2/__init__.py because imports are for convenience of cmd2 developers and backwards compatibility * F821 undefined name * ignored in cmd2 script files which are intended to run only within cmd2 applications via pyscript where "app" and "cmd" are defined
* Use setuptools_scm for version numberskotfu2018-07-291-2/+10
|
* Deprecated CmdResult helper class and promoted CommandResultTodd Leonhardt2018-06-231-1/+2
| | | | | | | | | | | | | | These classes are subtly different, particularly in terms of their truthiness. CmdResult - attributes: out, err, war - truthy: if err is falsy CommandResult - attributes: stdout, stderr, data - truthy: if err is falsy AND data is not None So CmdResult was oriented to provide essentially info, error, and warning messages to the user (typically as stirngs), whereas CommandResult is geared towards providing info and error messages to the user as strings in addition to data to the user in a command-specific format which is arbitrary other than it should never be None if the command succeeds.
* Working on improving type hintingTodd Leonhardt2018-06-091-0/+1
| | | | | Also: - Refactored perror() to remove a rarely used optional argument which was unecessary
* Add EmptyStatement exception to default importskotfu2018-05-231-1/+1
|
* Add Statement to default importkotfu2018-05-151-1/+1
|
* Extract AddSubmenu() into it’s own modulekotfu2018-05-061-1/+1
|
* Add default imports back inkotfu2018-05-061-0/+2
|
* Addressed comments.Eric Lin2018-05-021-2/+0
|
* Merge remote-tracking branch 'origin/master' into bash_completionEric Lin2018-04-271-18/+0
|\ | | | | | | Updated argcomplete_bridge to use new constants/utils.
* | Removed the expensive imports from cmd2/__init__.pyEric Lin2018-04-251-2/+2
| | | | | | | | | | | | | | Added some shared definitions to cmd2/__init__.py -> maybe there's a better place for these? Figured out how to trick bash into showing argument hints. It's a bit weird. Updated all of the tests and examples to import cmd2 resources from their new location without the automatic imports in cmd2/__init__.py For #369
* | Initial customization of CompletionFinderEric Lin2018-04-241-0/+17
|/
* Cleaned up __init__.pyTodd Leonhardt2018-04-171-5/+2
| | | | | Removed things which were only needed for unit tests from __init__.py - Converted to importing from cmd2.cmd2.<foo> within the relevant unit tests
* Fix unit tests on package branchTodd Leonhardt2018-04-171-3/+3
|
* Most of the unit tests fixed.kotfu2018-04-161-1/+3
|
* Basic structure for cmd2 as a packagekotfu2018-04-161-0/+6
|
* Revert "Basic structure for cmd2 as a package"kotfu2018-04-161-6/+0
| | | | This reverts commit 4a3d01b679c5db7f6cb670ca981a953eb3b98dc5.
* Basic structure for cmd2 as a packagekotfu2018-04-161-0/+6
Still have a fair amount of work to do to get this sorted.