Find a parser in the hierarchy based on a sequence of subcommand names. :param subcommand_path: sequence of subcommand names leading to the target parser :return: the discovered parser :raises ValueError: if any subcommand in the path is not found or a level doesn't support
(self, subcommand_path: Iterable[str])
| 755 | updated_parsers.add(subcmd_parser) |
| 756 | |
| 757 | def find_parser(self, subcommand_path: Iterable[str]) -> "Cmd2ArgumentParser": |
| 758 | """Find a parser in the hierarchy based on a sequence of subcommand names. |
| 759 | |
| 760 | :param subcommand_path: sequence of subcommand names leading to the target parser |
| 761 | :return: the discovered parser |
| 762 | :raises ValueError: if any subcommand in the path is not found or a level doesn't support subcommands |
| 763 | """ |
| 764 | parser = self |
| 765 | for name in subcommand_path: |
| 766 | subparsers_action = parser.get_subparsers_action() |
| 767 | if name not in subparsers_action._name_parser_map: |
| 768 | raise ValueError(f"Subcommand '{name}' does not exist for '{parser.prog}'") |
| 769 | parser = subparsers_action._name_parser_map[name] |
| 770 | return parser |
| 771 | |
| 772 | def attach_subcommand( |
| 773 | self, |