#!/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() { await initializeCompletion(); wrapCommandErrors(main); const cli = createMain(main); const { configPath, rawArgs } = extractConfigArgument(process.argv.slice(2)); const contextFree = new Set(["login", "logout", "whoami"]); 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; });