Generates a string representing the CLI invocation as if typed directly into the command line. Returns: A string representing the command invocation.
(self, include_root_command: bool = False)
| 219 | return args |
| 220 | |
| 221 | def to_cli_string(self, include_root_command: bool = False) -> Text: |
| 222 | """ |
| 223 | Generates a string representing the CLI invocation as if typed directly into the |
| 224 | command line. |
| 225 | |
| 226 | Returns: |
| 227 | A string representing the command invocation. |
| 228 | """ |
| 229 | args = self.to_cli_args(include_root_command=include_root_command) |
| 230 | |
| 231 | text_renderables: list[Text] = [] |
| 232 | for arg in args: |
| 233 | text_renderables.append( |
| 234 | Text(shlex.quote(str(arg))) |
| 235 | if arg != ValueNotSupplied() |
| 236 | else Text("???", style="bold black on red") |
| 237 | ) |
| 238 | return Text(" ").join(text_renderables) |