MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / _complete_flags

Method _complete_flags

tests/test_argparse_completer.py:1269–1278  ·  view source on GitHub ↗

Override so flags with 'complete_when_ready' set to True will complete only when app is ready

(self, text: str, line: str, begidx: int, endidx: int, used_flags: set[str])

Source from the content-addressed store, hash-verified

1267# Custom ArgparseCompleter-based class
1268class CustomCompleter(argparse_completer.ArgparseCompleter):
1269 def _complete_flags(self, text: str, line: str, begidx: int, endidx: int, used_flags: set[str]) -> Completions:
1270 """Override so flags with 'complete_when_ready' set to True will complete only when app is ready"""
1271 # Find flags which should not be completed and place them in used_flags
1272 for flag in self._flags:
1273 action = self._flag_to_action[flag]
1274 app: CustomCompleterApp = cast(CustomCompleterApp, self._cmd2_app)
1275 if action.get_complete_when_ready() and not app.is_ready:
1276 used_flags.append(flag)
1277
1278 return super()._complete_flags(text, line, begidx, endidx, used_flags)
1279
1280
1281# Add a custom argparse action attribute

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected