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 { YargsChecker } from "../../common/validators/lib.js";
import { ProjectIsSetValidator } from "../../common/validators/project-name-validator.js";
import { create } from "../../variable/create/handler.js";
export default {
    desc: "Creates a new variable for a branch",
    command: "create",
    builder: (yargs) => {
        return yargs
            .option("name", {
            type: "string",
            describe: "The name of the variable to create",
        })
            .option("value", {
            type: "string",
            describe: "The value of the variable to create",
        })
            .option("is-secret", {
            type: "boolean",
            describe: "Is the variable a secret",
        })
            .option("branch", {
            type: "string",
            describe: "The branch where the variable should be set",
        })
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
        })
            .option("project", {
            type: "string",
            describe: "The project name",
        })
            .demandOption(["name", "value", "is-secret", "branch"])
            .middleware([setBlocking, authenticate, configure, identify])
            .check(async (argv) => {
            return await new YargsChecker(new ProjectIsSetValidator()).check(argv);
        });
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo variable create" });
        await create(argv);
    },
};
//# sourceMappingURL=create.js.map