Files
kuber/index.ts
T
2026-09-27 10:40:50 +00:00

34 lines
1.0 KiB
TypeScript

#!/usr/bin/env bun
import { createMain } from "citty";
import { initializeCompletion, main } from "./command/main";
import { provideContext } from "./lib/context";
import { extractConfigArgument } from "./lib/config";
import { formatUnknownError, wrapCommandErrors } from "./lib/error";
async function run() {
const { configPath, rawArgs } = extractConfigArgument(process.argv.slice(2));
// citty resolves every preceding lazy command while looking up an alias.
if (rawArgs[0] === "fuck") rawArgs[0] = "rollback";
if (
rawArgs.length === 0 ||
rawArgs[0] === "complete" ||
rawArgs[0] === "--help" ||
rawArgs[0] === "-h"
)
await initializeCompletion();
wrapCommandErrors(main);
const cli = createMain(main);
const contextFree = new Set(["login", "logout", "whoami", "maintenance"]);
if (rawArgs[0] && contextFree.has(rawArgs[0])) {
await cli({ rawArgs });
return;
}
await provideContext(() => cli({ rawArgs }), configPath);
}
run().catch((e) => {
console.error(formatUnknownError(e));
process.exitCode = 1;
});