import { getCommandName } from "../types/command.js";
export function formatCommandHelp(commands) {
    return commands
        .filter((command) => !command.hidden)
        .map((command) => {
        const usage = command.usage ? ` ${command.usage}` : "";
        return `${getCommandName(command)}${usage} - ${command.description}`;
    })
        .join("\n");
}
export function parseLimit(value, fallback, max = 100) {
    const parsed = Number(value.trim() || fallback);
    if (!Number.isFinite(parsed) || parsed <= 0)
        return fallback;
    return Math.min(Math.floor(parsed), max);
}
export function compactPath(value, max) {
    if (value.length <= max)
        return value;
    return `...${value.slice(-(max - 3))}`;
}
export function firstLine(value, max = 120) {
    const line = value.split(/\r?\n/)[0]?.trim() ?? "";
    return line.length > max ? `${line.slice(0, max - 3)}...` : line;
}
