Generates a list of strings representing the CLI invocation based on the user input data. Returns: A list of strings that can be passed to subprocess.run to execute the command.
(self, include_root_command: bool = False)
| 78 | command_schema: CommandSchema | None = None |
| 79 | |
| 80 | def to_cli_args(self, include_root_command: bool = False) -> list[str]: |
| 81 | """ |
| 82 | Generates a list of strings representing the CLI invocation based on the user input data. |
| 83 | |
| 84 | Returns: |
| 85 | A list of strings that can be passed to subprocess.run to execute the command. |
| 86 | """ |
| 87 | cli_args = self._to_cli_args() |
| 88 | if not include_root_command: |
| 89 | cli_args = cli_args[1:] |
| 90 | |
| 91 | return cli_args |
| 92 | |
| 93 | def _to_cli_args(self) -> list[str]: |
| 94 | args: list[str] = [self.name] |