feat: add send --json, logger cleanup, and resilient Claude parsing

This commit is contained in:
Peter Steinberger
2025-11-25 04:08:42 +01:00
parent d7cc94333a
commit d1923e6efe
8 changed files with 165 additions and 28 deletions

View File

@@ -1,7 +1,8 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createMockTwilio } from "../test/mocks/twilio.js";
import { statusCommand } from "./commands/status.js";
import { createDefaultDeps, defaultRuntime } from "./index.js";
import { createDefaultDeps } from "./index.js";
import { defaultRuntime } from "./runtime.js";
import * as providerWeb from "./provider-web.js";
vi.mock("twilio", () => {
@@ -82,6 +83,28 @@ describe("CLI commands", () => {
expect(wait).not.toHaveBeenCalled();
});
it("send command outputs JSON when requested", async () => {
const twilio = (await import("twilio")).default;
twilio._client.messages.create.mockResolvedValue({ sid: "SMJSON" });
const logSpy = vi.spyOn(defaultRuntime, "log");
await index.program.parseAsync(
[
"send",
"--to",
"+1555",
"--message",
"hi",
"--wait",
"0",
"--json",
],
{ from: "user" },
);
expect(logSpy).toHaveBeenCalledWith(
expect.stringContaining("\"sid\": \"SMJSON\""),
);
});
it("login alias calls web login", async () => {
const spy = vi.spyOn(providerWeb, "loginWeb").mockResolvedValue();
await index.program.parseAsync(["login"], { from: "user" });