(style: Style, *fragments: tuple[str, str])
| 83 | |
| 84 | |
| 85 | def _fmt(style: Style, *fragments: tuple[str, str]) -> None: |
| 86 | # prompt_toolkit's print_formatted_text constructs a Win32Output on |
| 87 | # Windows that requires a real console handle, raising |
| 88 | # NoConsoleScreenBufferError when stdout is a pipe, file, or captured |
| 89 | # subprocess stream. Fall back to plain text when the output isn't a |
| 90 | # usable console. |
| 91 | if not _use_color(force_off=False): |
| 92 | for _, text in fragments: |
| 93 | sys.stdout.write(text) |
| 94 | sys.stdout.flush() |
| 95 | return |
| 96 | print_formatted_text(FormattedText(list(fragments)), style=style, end="") |
| 97 | |
| 98 | |
| 99 | def _format_tool_line(name: str, args: str, width: int = 78) -> str: |
no test coverage detected