()
| 11 | |
| 12 | |
| 13 | def command_tuples(): |
| 14 | root: tuple[str, ...] = () |
| 15 | commands = [root] |
| 16 | |
| 17 | def recurse_parser(parser: ArgumentParser, parents: tuple[str, ...] = root) -> None: |
| 18 | for positional in parser._get_positional_actions(): |
| 19 | if positional.help != SUPPRESS and isinstance(positional.choices, dict): |
| 20 | public_cmds = shtab.get_public_subcommands(positional) |
| 21 | for subcmd, subparser in positional.choices.items(): |
| 22 | cmd = (*parents, subcmd) |
| 23 | if subcmd in public_cmds: |
| 24 | commands.append(cmd) |
| 25 | recurse_parser(subparser, cmd) |
| 26 | |
| 27 | main_parser = get_main_parser() |
| 28 | recurse_parser(main_parser) |
| 29 | |
| 30 | # the no. of commands will usually go up, |
| 31 | # but if we ever remove commands and drop below, adjust the magic number accordingly |
| 32 | assert len(commands) >= 116 |
| 33 | return sorted(commands) |
| 34 | |
| 35 | |
| 36 | def ids(values): |
nothing calls this directly
no test coverage detected