"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@oclif/command");
const cli_ux_1 = require("cli-ux");
const _ = require("lodash");
class Commands extends command_1.Command {
    async run() {
        const { flags } = this.parse(Commands);
        let commands = this.config.commands;
        if (!flags.hidden) {
            commands = commands.filter(c => !c.hidden);
        }
        commands = _.sortBy(commands, 'id');
        if (flags.json) {
            cli_ux_1.default.styledJSON(commands);
        }
        else {
            for (let c of commands) {
                this.log(c.id);
            }
        }
    }
}
Commands.description = 'list all the commands';
Commands.flags = {
    help: command_1.flags.help({ char: 'h' }),
    json: command_1.flags.boolean({ char: 'j', description: 'output in json format' }),
    hidden: command_1.flags.boolean({ description: 'also show hidden commands' }),
};
exports.default = Commands;
