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 { rotateToken } from "../../tunnel/rotate-token/handler.js";
export default {
    desc: "Rotates the token for a tunnel in your account",
    command: "rotate-token",
    builder: (yargs) => {
        return yargs
            .usage("$0 tunnel rotate-token --tunnel-id <id> [options]")
            .option("tunnel-id", {
            type: "string",
            describe: "The ID of the tunnel to rotate the token for",
        })
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
            alias: "apikey",
        })
            .demandOption(["tunnel-id"])
            .demandOption("api-key", "You must provide an API key with --api-key")
            .example([
            [
                "$0 tunnel rotate-token --tunnel-id tnl_TRMZwunq2PLNQDwhu6A04Bmx",
                "Rotate the authentication token for a tunnel",
            ],
            [
                "$0 tunnel rotate-token --tunnel-id tnl_TRMZwunq2PLNQDwhu6A04Bmx --account my-account",
                "Explicitly specify the account",
            ],
        ])
            .middleware([authenticate, configure, fetchAccount, identify]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo tunnel rotate-token" });
        await rotateToken(argv);
    },
};
//# sourceMappingURL=rotate-token.js.map