Skip to content

styleText ​

styleText wraps text in ANSI escape sequences for terminal output.

SignaturestyleText(format, text): string
tyrus
import { styleText } from "tyrus:utils";

printError(styleText("green", "created"));
printError(styleText(["bold", "cyan"], "tyrus"));
printError(styleText.bold.red("failed"));

The compiler recognizes multiple call shapes. Style names must be string literals or static style members so invalid styles are reported at compile time.

Use stderr for terminal chrome

Styled status messages should usually go to stderr. Keep stdout for normal data output.