Skip to main content
Version: v0.0.4

Function: formatDiagnostic()

formatDiagnostic(err): string

Render a CliError as a single value-free stderr line: cosyte: <CODE>: <message>. The message is already value-free by the CliError contract; this only prefixes the tool name and the code so scripts and humans can branch on a stable token.

Parameters

err

CliError

The CLI error to render.

Returns

string

The stderr line (no trailing newline).

Example

import { CliError, CLI_CODES, EXIT, formatDiagnostic } from "@cosyte/cli";

formatDiagnostic(new CliError(CLI_CODES.CLI_USAGE, EXIT.USAGE, "missing <file> argument"));
// => "cosyte: CLI_USAGE: missing <file> argument"