Skip to content

Commit 1a34f35

Browse files
committed
Added CompletionError exception class
1 parent 1176c0c commit 1a34f35

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cmd2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
pass
1212

1313
from .ansi import style
14-
from .argparse_custom import Cmd2ArgumentParser, CompletionItem
14+
from .argparse_custom import Cmd2ArgumentParser, CompletionError, CompletionItem
1515
from .cmd2 import Cmd, Statement, EmptyStatement, categorize
1616
from .cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args, with_category
1717
from .constants import DEFAULT_SHORTCUTS

cmd2/argparse_custom.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ def generate_range_error(range_min: int, range_max: Union[int, float]) -> str:
221221
return err_str
222222

223223

224+
class CompletionError(Exception):
225+
"""
226+
Raised during tab-completion operations to report any sort of error you want printed by the AutoCompleter
227+
228+
Example use cases
229+
1. Reading a database to retrieve a tab completion data set failed
230+
2. A previous command line argument that determines the data set being completed is invalid
231+
"""
232+
pass
233+
234+
224235
class CompletionItem(str):
225236
"""
226237
Completion item with descriptive text attached

0 commit comments

Comments
 (0)