terminal-styling
Version:
A npm package to add some styling to terminal output
64 lines (63 loc) • 2.19 kB
TypeScript
import { message } from './types';
/**
* Utility class for styled and categorized console output.
*
* Provides methods for printing error, warning, info, debug, table,
* and custom-colored messages using ANSI escape codes.
*
* @export
* @class Console
*/
export declare class Console {
/**
* Logs an error message in red.
*
* @param {message} consoleLogMessage - The message to log.
* @example
* console.err("This is an error");
*/
err: (consoleLogMessage: message) => void;
/**
* Logs a warning message in yellow.
*
* @param {message} consoleLogMessage - The warning message.
* @example
* console.warn("This is a warning");
*/
warn: (consoleLogMessage: message) => void;
/**
* Logs an informational message in green.
*
* @param {message} consoleLogMessage - The info message.
* @example
* console.info("System ready");
*/
info: (consoleLogMessage: message) => void;
/**
* Logs data as a formatted table using process.stdout.write.
*
* @param {...any[]} args - Data to be displayed in a table format.
* @example
* console.table([{ name: "Alice", age: 25 }, { name: "Bob", age: 30 }]);
*/
table: (...args: any[]) => void;
/**
* Logs a message with a custom foreground and optional background color using hex codes.
*
* @param {string} text_color - Foreground color as a hex string (e.g. "ff0000").
* @param {string} consoleLogMessage - The message to log.
* @param {string} [bg_color] - Optional background color as a hex string (e.g. "000000").
* @example
* console.customColor("00ffff", "Cyan text");
* console.customColor("ffffff", "White on black", "000000");
*/
customColor: (text_color: string, consoleLogMessage: string, bg_color?: string | undefined) => void;
/**
* Logs a debug message without styling.
*
* @param {message} consoleLogMessage - The debug message.
* @example
* console.debug("Debug: variable x = 42");
*/
debug: (consoleLogMessage: message) => void;
}