import { captureEvent } from "../common/analytics/lib.js";
import { authenticate } from "../common/middleware/authentication.js";
import { confirmLinkedConfig } from "../common/middleware/confirm-linked-config.js";
import { fetchAccount } from "../common/middleware/get-account-param.js";
import { fetchProject } from "../common/middleware/get-project-param.js";
import { configure } from "../common/middleware/user-configuration.js";
import { identify } from "../common/middleware/user-identification.js";
import { list } from "../list/handler.js";
export default {
    desc: "Lists all deployed Zuplo APIs",
    command: "list",
    builder: (yargs) => {
        return yargs
            .usage("$0 list [options]")
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
            alias: "apikey",
        })
            .option("project", {
            type: "string",
            describe: "The project name",
        })
            .option("account", {
            type: "string",
            describe: "The account name",
        })
            .option("show-details", {
            type: "boolean",
            alias: "d",
            describe: "Include deployment metadata in the output",
            default: false,
        })
            .option("output", {
            type: "string",
            alias: "o",
            describe: "Output format",
            choices: ["default", "json"],
            default: "default",
        })
            .option("self-hosted-endpoint", {
            type: "string",
            describe: "The endpoint of your self-hosted service to deploy to",
        })
            .example([
            ["$0 list", "List all deployed environments for your project"],
            [
                "$0 list --show-details",
                "List all deployed environments with project and deployment names",
            ],
            ["$0 list --output json", "List deployed environments as JSON"],
            [
                "$0 list --account my-account --project my-project",
                "Explicitly specify the account and project",
            ],
        ])
            .middleware([
            authenticate,
            configure,
            confirmLinkedConfig,
            fetchAccount,
            fetchProject,
            identify,
        ]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo list" });
        await list(argv);
    },
};
//# sourceMappingURL=list.js.map