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 { update } from "../../variable/update/handler.js";
import { fetchAccount } from "../../common/middleware/get-account-param.js";
import { fetchProject } from "../../common/middleware/get-project-param.js";
export default {
    desc: "Updates an existing variable for a branch",
    command: "update",
    builder: (yargs) => {
        return yargs
            .option("name", {
            type: "string",
            describe: "The name of the variable to update",
        })
            .option("value", {
            type: "string",
            describe: "The value of the variable to update",
        })
            .option("branch", {
            type: "string",
            describe: "The branch where the variable exists",
        })
            .option("project", {
            type: "string",
            describe: "The project name",
        })
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
        })
            .option("account", {
            type: "string",
            describe: "The account name",
        })
            .demandOption(["name", "value", "branch"])
            .middleware([
            setBlocking,
            authenticate,
            configure,
            fetchAccount,
            fetchProject,
            identify,
        ]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo variable update" });
        await update(argv);
    },
};
//# sourceMappingURL=update.js.map