| 764 | pass |
| 765 | |
| 766 | def run(self, args: argparse.Namespace) -> Any: |
| 767 | # This is a bit gross, but to determine the first position argument to |
| 768 | # `run` we have no choice but to hardcode the list of `run` options that |
| 769 | # take a value. E.g., in `run --entrypoint bash service`, we need to |
| 770 | # return `service`, not `bash`. We also distinguish between `run --help |
| 771 | # workflow` and `run workflow --help`: the former asks for help on the |
| 772 | # `run` command while the latter asks for help on the named `workflow`. |
| 773 | |
| 774 | KNOWN_OPTIONS_WITH_ARGUMENT = [ |
| 775 | "-d", |
| 776 | "--detach", |
| 777 | "--name", |
| 778 | "--entrypoint", |
| 779 | "-e", |
| 780 | "-l", |
| 781 | "--label", |
| 782 | "-p", |
| 783 | "--publish", |
| 784 | "-v", |
| 785 | "--volume", |
| 786 | "-w", |
| 787 | "--workdir", |
| 788 | ] |
| 789 | |
| 790 | setattr(args, "workflow", None) |
| 791 | setattr(args, "help", False) |
| 792 | arg_iter = iter(args.unknown_subargs) |
| 793 | for arg in arg_iter: |
| 794 | if arg in ["-h", "--help"]: |
| 795 | setattr(args, "help", True) |
| 796 | elif arg in KNOWN_OPTIONS_WITH_ARGUMENT: |
| 797 | # This is an option that's known to take a value, so skip the |
| 798 | # next argument too. |
| 799 | next(arg_iter, None) |
| 800 | elif arg.startswith("-"): |
| 801 | # Flag option. Skip it. |
| 802 | pass |
| 803 | else: |
| 804 | # Found a positional argument. Save it. |
| 805 | setattr(args, "workflow", arg) |
| 806 | break |
| 807 | |
| 808 | super().run(args) |
| 809 | |
| 810 | def handle_composition( |
| 811 | self, args: argparse.Namespace, composition: Composition |