Call read_input to use a custom history and an argument parser.
(self, _)
| 82 | |
| 83 | @cmd2.with_category(EXAMPLE_COMMANDS) |
| 84 | def do_custom_parser(self, _) -> None: |
| 85 | """Call read_input to use a custom history and an argument parser.""" |
| 86 | parser = cmd2.Cmd2ArgumentParser(prog="", description="An example parser") |
| 87 | parser.add_argument("-o", "--option", help="an optional arg") |
| 88 | parser.add_argument("arg_1", help="a choice for this arg", metavar="arg_1", choices=["my_choice", "your_choice"]) |
| 89 | parser.add_argument("arg_2", help="path of something", completer=cmd2.Cmd.path_complete) |
| 90 | |
| 91 | self.poutput("Tab completing with argument parser and using custom history") |
| 92 | self.poutput(parser.format_usage()) |
| 93 | |
| 94 | try: |
| 95 | input_str = self.read_input("> ", history=self.custom_history, parser=parser) |
| 96 | except EOFError: |
| 97 | pass |
| 98 | else: |
| 99 | self.custom_history.append(input_str) |
| 100 | |
| 101 | @cmd2.with_category(EXAMPLE_COMMANDS) |
| 102 | def do_read_password(self, _) -> None: |
nothing calls this directly
no test coverage detected