import { captureEvent } from "../common/analytics/lib.js";
import { authenticate } from "../common/middleware/authentication.js";
import { configure } from "../common/middleware/user-configuration.js";
import { identify } from "../common/middleware/user-identification.js";
import setBlocking from "../common/output.js";
import { link } from "../link/handler.js";
import { fetchAccount } from "../common/middleware/get-account-param.js";
import { fetchProject } from "../common/middleware/get-project-param.js";
import { fetchEnvironment } from "../common/middleware/get-environment-param.js";
export default {
    desc: "Links information from your Zuplo account to your local machine",
    command: "link",
    builder: (yargs) => {
        return yargs
            .option("dir", {
            type: "string",
            describe: "The directory containing your Zuplo API",
            default: ".",
            normalize: true,
            hidden: true,
        })
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
        })
            .option("project", {
            type: "string",
            describe: "The project name",
        })
            .option("account", {
            type: "string",
            describe: "The account name",
        })
            .option("environment", {
            type: "string",
            describe: "The environment name",
        })
            .option("fetch-environments", {
            type: "boolean",
            describe: "Fetch the environments for your project from Zuplo. If this is false, then the environment will automatically be detected from the git branch.",
            default: true,
        })
            .middleware([
            setBlocking,
            authenticate,
            configure,
            fetchAccount,
            fetchProject,
            fetchEnvironment,
            identify,
        ]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo link" });
        await link(argv);
    },
};
//# sourceMappingURL=link.js.map