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

Method do_custom_choices

examples/read_input.py:40–52  ·  view source on GitHub ↗

Call read_input to use custom history and choices.

(self, _)

Source from the content-addressed store, hash-verified

38
39 @cmd2.with_category(EXAMPLE_COMMANDS)
40 def do_custom_choices(self, _) -> None:
41 """Call read_input to use custom history and choices."""
42 self.poutput("Tab completing with static choices list and using custom history")
43 try:
44 input_str = self.read_input(
45 "> ",
46 history=self.custom_history,
47 choices=["choice_1", "choice_2", "choice_3"],
48 )
49 except EOFError:
50 pass
51 else:
52 self.custom_history.append(input_str)
53
54 def choices_provider(self) -> cmd2.Choices:
55 """Example choices provider function."""

Callers

nothing calls this directly

Calls 3

poutputMethod · 0.80
read_inputMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected