import { captureEvent } from "../../common/analytics/lib.js";
import { authenticate } from "../../common/middleware/authentication.js";
import { fetchAccount } from "../../common/middleware/get-account-param.js";
import { configure } from "../../common/middleware/user-configuration.js";
import { identify } from "../../common/middleware/user-identification.js";
import { update } from "../../custom-domain/update/handler.js";
export default {
    desc: "Updates the deployment assignment for a custom domain",
    command: "update",
    builder: (yargs) => {
        return yargs
            .usage("$0 custom-domain update --hostname <hostname> [options]")
            .option("hostname", {
            type: "string",
            describe: "The hostname for the custom domain",
        })
            .option("deployment-name", {
            type: "string",
            describe: "The deployment name to assign the custom domain to. Omit to detach the current assignment.",
        })
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
            alias: "apikey",
        })
            .option("account", {
            type: "string",
            describe: "The account name",
        })
            .option("output", {
            type: "string",
            alias: "o",
            describe: "Output format",
            choices: ["default", "json"],
            default: "default",
        })
            .demandOption(["hostname"])
            .demandOption("api-key", "You must provide an API key with --api-key")
            .example([
            [
                "$0 custom-domain update --hostname api.example.com --deployment-name production-deployment",
                "Reassign a custom domain to a deployment",
            ],
            [
                "$0 custom-domain update --hostname api.example.com --output json",
                "Update a custom domain and output the result as JSON",
            ],
            [
                "$0 custom-domain update --hostname api.example.com",
                "Detach the current deployment assignment while preserving the stage",
            ],
            [
                "$0 custom-domain update --hostname docs.example.com --deployment-name portal-deployment --account my-account",
                "Update a custom domain on a specific account",
            ],
        ])
            .middleware([authenticate, configure, fetchAccount, identify]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo custom-domain update" });
        await update(argv);
    },
};
//# sourceMappingURL=update.js.map