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 { create } from "../../custom-domain/create/handler.js";
export default {
    desc: "Creates a custom domain in your account",
    command: "create",
    builder: (yargs) => {
        return yargs
            .usage("$0 custom-domain create --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",
        })
            .option("custom-domain-type", {
            type: "string",
            describe: "The type of custom domain to create. Defaults to api server-side.",
            choices: ["api", "dev-portal"],
        })
            .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 create --hostname api.example.com",
                "Create an unassigned custom domain",
            ],
            [
                "$0 custom-domain create --hostname api.example.com --output json",
                "Create a custom domain and output the result as JSON",
            ],
            [
                "$0 custom-domain create --hostname api.example.com --deployment-name production-deployment",
                "Create and assign a custom domain to a deployment",
            ],
            [
                "$0 custom-domain create --hostname docs.example.com --deployment-name production-deployment --custom-domain-type dev-portal --account my-account",
                "Create a dev portal custom domain on a specific account",
            ],
        ])
            .middleware([authenticate, configure, fetchAccount, identify]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo custom-domain create" });
        const commandArguments = argv;
        const handlerArguments = {
            ...commandArguments,
            stage: commandArguments["custom-domain-type"],
        };
        await create(handlerArguments);
    },
};
//# sourceMappingURL=create.js.map