Utilities
Logging utilities for CLI output formatting. The module exports a singleton instance as Utilities.
Diagram
Usage
ts
import { UtilitiesClass } from "@briklab/lib/cli-john";
let Utilities = new UtilitiesClass();
Utilities.info("Starting...");
Utilities.warning("Missing config, using defaults.");
Utilities.error("Failed to run command.");Class: UtilitiesClass
Properties
| Property | Type | Description |
|---|---|---|
styleSheet | StyleSheet | Style registry used for tags. |
tags | Record<string, TagConfig> | Tag configuration map. |
TagConfig shape:
ts
{
tag: string;
showErrorInTag: boolean;
paddingLeft: number;
paddingRight: number;
styleName: string;
}Constructor
Creates default tags: error, warning, and info, and assigns default colors:
error: red + boldwarning: orange + boldinfo: blue
Methods
.addTag(name: string, config?: Partial<TagConfig>)
| Argument | Type | Description |
|---|---|---|
name | string | The tag name. |
config | Partial<TagConfig> | Tag configuration overrides. |
Adds a new tag or overwrites an existing tag config. Returns this for chaining.
.setTagStyle(tagName: string, style: InlineStyle)
| Argument | Type | Description |
|---|---|---|
tagName | string | The tag name to style. |
style | InlineStyle | Inline style instance. |
Assigns a style to a tag and registers it in styleSheet. Returns this.
.log(tagName: string, ...messages: any[])
| Argument | Type | Description |
|---|---|---|
tagName | string | The tag to use for formatting. |
messages | any[] | Messages forwarded to console.log. |
Logs a message using the tag's formatting. If the tag does not exist, it logs with a plain console.log.
.error(...messages: any[])
Shortcut for log("error", ...).
.warning(...messages: any[])
Shortcut for log("warning", ...).
.info(...messages: any[])
Shortcut for log("info", ...).