"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getUsage(cmd) {
    return `${cmd.name ? cmd.name + " " : ""}${cmd.positionalParams
        .map(arg => `{${arg.name}:${arg.type.itemToString()}}${starIfMultiple(arg.type)}`)
        .join(" ")} ${Object.values(cmd.namedParams)
        .filter(v => !v.isOptional)
        .map(v => `--${v.name}={${v.type.itemToString()}}${starIfMultiple(v.type)}`)
        .join(" ")}`;
}
exports.getUsage = getUsage;
function printCmdHelp(info, cmd) {
    console.log(`usage: ${info.appName} ${getUsage(cmd)}`);
    console.log("");
    console.log(`      ${cmd.description}`);
    console.log("");
    console.log("Positional Parameters");
    for (const arg of cmd.positionalParams) {
        console.log(`      ${arg.name}: ${arg.type.toString()}    ${arg.description}`);
    }
    console.log();
    console.log("Required Parameters");
    printParameters("      ", Object.values(cmd.namedParams).filter(v => !v.isOptional));
    console.log();
    console.log("Optional Parameters");
    printParameters("      ", Object.values(cmd.namedParams).filter(v => v.isOptional));
}
exports.printCmdHelp = printCmdHelp;
function starIfMultiple(type) {
    if (type.getRealType().kind === "MultiValue") {
        return "*";
    }
    return "";
}
function printParameters(indentation, params) {
    for (const arg of Object.values(params)) {
        const short = arg.shortName !== undefined ? `-${arg.shortName}, ` : "";
        const val = arg.type.getRealType().kind === "NoValue"
            ? ""
            : `={${arg.type.itemToString()}}${starIfMultiple(arg.type)}`;
        console.log(`${indentation}${short}--${arg.name}${val}    ${arg.description}`);
    }
}
exports.printParameters = printParameters;
//# sourceMappingURL=printCmdHelp.js.map