The CLI source (242 files, ~14k lines) was gitignored during the earlier cli→cli-v2 reorg so only the published npm package carried it. That blocks the GitHub Actions release workflow (release-cli.yml), which clones the repo fresh on each runner and needs the source to compile binaries via `bun build --compile`. Moves the gitignore from root-level to `apps/cli-v2/.gitignore` with only the usual build artefacts excluded (node_modules, dist, .turbo, .cache). Source is now in git at apps/cli-v2/src/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { parseArgv } from "~/cli/argv.js";
|
|
|
|
describe("parseArgv", () => {
|
|
it("parses bare command", () => {
|
|
const r = parseArgv(["node", "cli.js", "login"]);
|
|
expect(r.command).toBe("login");
|
|
expect(r.positionals).toEqual([]);
|
|
expect(r.flags).toEqual({});
|
|
});
|
|
|
|
it("parses command with positionals", () => {
|
|
const r = parseArgv(["node", "cli.js", "send", "alice", "hello world"]);
|
|
expect(r.command).toBe("send");
|
|
expect(r.positionals).toEqual(["alice", "hello world"]);
|
|
});
|
|
|
|
it("parses flags before command", () => {
|
|
const r = parseArgv(["node", "cli.js", "--version"]);
|
|
expect(r.command).toBe("");
|
|
expect(r.flags.version).toBe(true);
|
|
});
|
|
|
|
it("parses flags with values", () => {
|
|
const r = parseArgv(["node", "cli.js", "peers", "--mesh", "my-team", "--json"]);
|
|
expect(r.command).toBe("peers");
|
|
expect(r.flags.mesh).toBe("my-team");
|
|
expect(r.flags.json).toBe(true);
|
|
});
|
|
|
|
it("parses short flags", () => {
|
|
const r = parseArgv(["node", "cli.js", "-y", "-q"]);
|
|
expect(r.flags.y).toBe(true);
|
|
expect(r.flags.q).toBe(true);
|
|
});
|
|
|
|
it("empty args", () => {
|
|
const r = parseArgv(["node", "cli.js"]);
|
|
expect(r.command).toBe("");
|
|
expect(r.positionals).toEqual([]);
|
|
});
|
|
});
|