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 { update } from "../../variable/update/handler.js";
export default {
    desc: "Updates an existing variable for a branch",
    command: "update",
    builder: (yargs) => {
        return yargs
            .usage("$0 variable update --name <name> --value <value> --branch <branch> [options]")
            .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",
            alias: "apikey",
        })
            .option("account", {
            type: "string",
            describe: "The account name",
        })
            .demandOption(["name", "value", "branch"])
            .example([
            [
                "$0 variable update --name API_KEY --value new-secret-key --branch main",
                "Update a variable on the main branch",
            ],
            [
                "$0 variable update --name BASE_URL --value https://api.prod.example.com --branch production --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 variable update" });
        await update(argv);
    },
};
//# sourceMappingURL=update.js.map