Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

31 lines · 1.4 KBRaw History
1import { dispatch, type Registry } from "./cli.js";
2import { adminCommands, agentGroup, secretGroup, tokenGroup, variableGroup } from "./commands/admin.js";
3import { authCommands, authGroup } from "./commands/auth.js";
4import { issueGroup } from "./commands/issue.js";
5import { migrateGroup } from "./commands/migrate.js";
6import { prGroup } from "./commands/pr.js";
7import { repoGroup } from "./commands/repo.js";
8import { runGroup } from "./commands/run.js";
9import { runnerCommand } from "./commands/runner.js";
10import { upgradeCommand } from "./commands/upgrade.js";
11import { workflowGroup } from "./commands/workflow.js";
12import { CliError, processIo, type Io } from "./io.js";
13
14export const registry: Registry = {
15 groups: [authGroup, repoGroup, prGroup, issueGroup, runGroup, workflowGroup, secretGroup, variableGroup, tokenGroup, agentGroup, migrateGroup],
16 commands: [...authCommands, ...adminCommands, runnerCommand, upgradeCommand],
17};
18
19/** Runs the CLI and returns its exit code (never calls process.exit). */
20export async function main(argv: string[], io: Io = processIo()): Promise<number> {
21 try {
22 return await dispatch(registry, argv, io);
23 } catch (e) {
24 if (e instanceof CliError) {
25 io.stderr.write(`error: ${e.message}\n`);
26 return e.code;
27 }
28 io.stderr.write(`error: ${e instanceof Error ? (e.stack ?? e.message) : String(e)}\n`);
29 return 1;
30 }
31}