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

Method complete_set_value

cmd2/cmd2.py:4630–4659  ·  view source on GitHub ↗

Completes the value argument of set.

(
        self, text: str, line: str, begidx: int, endidx: int, arg_tokens: Mapping[str, Sequence[str]]
    )

Source from the content-addressed store, hash-verified

4628 return base_set_parser
4629
4630 def complete_set_value(
4631 self, text: str, line: str, begidx: int, endidx: int, arg_tokens: Mapping[str, Sequence[str]]
4632 ) -> Completions:
4633 """Completes the value argument of set."""
4634 param = arg_tokens["param"][0]
4635 try:
4636 settable = self.settables[param]
4637 except KeyError as ex:
4638 raise CompletionError(param + " is not a settable parameter") from ex
4639
4640 # Create a parser with a value field based on this settable
4641 settable_parser = self._build_base_set_parser()
4642
4643 # Settables with choices list the values of those choices instead of the arg name
4644 # in help text and this shows in completion hints. Set metavar to avoid this.
4645 arg_name = "value"
4646 settable_parser.add_argument(
4647 arg_name,
4648 metavar=arg_name,
4649 help=settable.description,
4650 choices=settable.choices,
4651 choices_provider=settable.choices_provider,
4652 completer=settable.completer,
4653 )
4654
4655 completer = argparse_completer.DEFAULT_AP_COMPLETER(settable_parser, self)
4656
4657 # Use raw_tokens since quotes have been preserved
4658 _, raw_tokens = self.tokens_for_completion(line, begidx, endidx)
4659 return completer.complete(text, line, begidx, endidx, raw_tokens[1:])
4660
4661 @classmethod
4662 def _build_set_parser(cls) -> Cmd2ArgumentParser:

Callers

nothing calls this directly

Calls 4

tokens_for_completionMethod · 0.95
CompletionErrorClass · 0.85
completeMethod · 0.45

Tested by

no test coverage detected