| 8 | |
| 9 | |
| 10 | def add_parsers(parser: argparse.ArgumentParser) -> None: |
| 11 | subparsers = parser.add_subparsers(dest='tool') |
| 12 | |
| 13 | cd_parser = subparsers.add_parser( |
| 14 | 'cd', help='cd to a subdir and run the command', |
| 15 | ) |
| 16 | cd_parser.add_argument('subdir') |
| 17 | cd_parser.add_argument('cmd', nargs=argparse.REMAINDER) |
| 18 | |
| 19 | ignore_exit_code_parser = subparsers.add_parser( |
| 20 | 'ignore-exit-code', help='run the command but ignore the exit code', |
| 21 | ) |
| 22 | ignore_exit_code_parser.add_argument('cmd', nargs=argparse.REMAINDER) |
| 23 | |
| 24 | n1_parser = subparsers.add_parser( |
| 25 | 'n1', help='run the command once per filename', |
| 26 | ) |
| 27 | n1_parser.add_argument('cmd', nargs=argparse.REMAINDER) |
| 28 | |
| 29 | |
| 30 | def _cmd_filenames(cmd: tuple[str, ...]) -> tuple[ |