Parse command line arguments. This function creates a parser object and adds subparsers for each command. The function then parses the command line arguments and returns the parsed arguments. Returns: The parsed command line arguments.
()
| 13 | |
| 14 | |
| 15 | def parse_cli_args() -> argparse.Namespace: |
| 16 | """Parse command line arguments. |
| 17 | |
| 18 | This function creates a parser object and adds subparsers for each command. The function then parses the |
| 19 | command line arguments and returns the parsed arguments. |
| 20 | |
| 21 | Returns: |
| 22 | The parsed command line arguments. |
| 23 | """ |
| 24 | parser = argparse.ArgumentParser(description="Utility for using Docker with Isaac Lab.") |
| 25 | |
| 26 | # We have to create separate parent parsers for common options to our subparsers |
| 27 | parent_parser = argparse.ArgumentParser(add_help=False) |
| 28 | parent_parser.add_argument( |
| 29 | "profile", nargs="?", default="base", help="Optional container profile specification. Example: 'base' or 'ros'." |
| 30 | ) |
| 31 | parent_parser.add_argument( |
| 32 | "--files", |
| 33 | nargs="*", |
| 34 | default=None, |
| 35 | help=( |
| 36 | "Allows additional '.yaml' files to be passed to the docker compose command. These files will be merged" |
| 37 | " with 'docker-compose.yaml' in their provided order." |
| 38 | ), |
| 39 | ) |
| 40 | parent_parser.add_argument( |
| 41 | "--env-files", |
| 42 | nargs="*", |
| 43 | default=None, |
| 44 | help=( |
| 45 | "Allows additional '.env' files to be passed to the docker compose command. These files will be merged with" |
| 46 | " '.env.base' in their provided order." |
| 47 | ), |
| 48 | ) |
| 49 | |
| 50 | # Actual command definition begins here |
| 51 | subparsers = parser.add_subparsers(dest="command", required=True) |
| 52 | subparsers.add_parser( |
| 53 | "start", |
| 54 | help="Build the docker image and create the container in detached mode.", |
| 55 | parents=[parent_parser], |
| 56 | ) |
| 57 | subparsers.add_parser( |
| 58 | "enter", help="Begin a new bash process within an existing Isaac Lab container.", parents=[parent_parser] |
| 59 | ) |
| 60 | config = subparsers.add_parser( |
| 61 | "config", |
| 62 | help=( |
| 63 | "Generate a docker-compose.yaml from the passed yamls, .envs, and either print to the terminal or create a" |
| 64 | " yaml at output_yaml" |
| 65 | ), |
| 66 | parents=[parent_parser], |
| 67 | ) |
| 68 | config.add_argument( |
| 69 | "--output-yaml", nargs="?", default=None, help="Yaml file to write config output to. Defaults to None." |
| 70 | ) |
| 71 | subparsers.add_parser( |
| 72 | "copy", help="Copy build and logs artifacts from the container to the host machine.", parents=[parent_parser] |