"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunestoneCommand = void 0;
exports.createCommand = createCommand;
const commander_1 = require("commander");
class RunestoneHelp extends commander_1.Help {
    commandUsage(cmd) {
        const usage = super.commandUsage(cmd);
        if (this.hasVisibleNonHelpOptions(cmd)) {
            return usage;
        }
        return usage
            .replace(/\s*\[options\]\s*/g, ' ')
            .replace(/\s{2,}/g, ' ')
            .trim();
    }
    visibleOptions(cmd) {
        const options = super.visibleOptions(cmd);
        return this.hasVisibleNonHelpOptions(cmd) ? options : [];
    }
    hasVisibleNonHelpOptions(cmd) {
        return super.visibleOptions(cmd).some((option) => option.short !== '-h' && option.long !== '--help');
    }
}
class RunestoneCommand extends commander_1.Command {
    createHelp() {
        return new RunestoneHelp();
    }
}
exports.RunestoneCommand = RunestoneCommand;
function createCommand(name) {
    return new RunestoneCommand(name).addHelpCommand(false);
}
//# sourceMappingURL=command.js.map