diff options
-rw-r--r-- | cmd2/__init__.py | 2 | ||||
-rw-r--r-- | cmd2/argparse_custom.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py index 2653051a..c496a4f7 100644 --- a/cmd2/__init__.py +++ b/cmd2/__init__.py @@ -11,7 +11,7 @@ except DistributionNotFound: pass from .ansi import style -from .argparse_custom import Cmd2ArgumentParser, CompletionItem +from .argparse_custom import Cmd2ArgumentParser, CompletionError, CompletionItem from .cmd2 import Cmd, Statement, EmptyStatement, categorize from .cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args, with_category from .constants import DEFAULT_SHORTCUTS diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py index 940d6064..4faddcab 100644 --- a/cmd2/argparse_custom.py +++ b/cmd2/argparse_custom.py @@ -221,6 +221,17 @@ def generate_range_error(range_min: int, range_max: Union[int, float]) -> str: return err_str +class CompletionError(Exception): + """ + Raised during tab-completion operations to report any sort of error you want printed by the AutoCompleter + + Example use cases + 1. Reading a database to retrieve a tab completion data set failed + 2. A previous command line argument that determines the data set being completed is invalid + """ + pass + + class CompletionItem(str): """ Completion item with descriptive text attached |