Add login alias for web QR and update docs/tests

This commit is contained in:
Peter Steinberger
2025-11-25 00:19:21 +01:00
parent 9dd257a92d
commit 9595964419
3 changed files with 23 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ 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 * as providerWeb from "./provider-web.js";
vi.mock("twilio", () => {
const { factory } = createMockTwilio();
@@ -55,6 +56,12 @@ describe("CLI commands", () => {
expect(wait).not.toHaveBeenCalled();
});
it("login alias calls web login", async () => {
const spy = vi.spyOn(providerWeb, "loginWeb").mockResolvedValue();
await index.program.parseAsync(["login"], { from: "user" });
expect(spy).toHaveBeenCalled();
});
it("status command prints JSON", async () => {
const twilio = (await import("twilio")).default;
twilio._client.messages.list

View File

@@ -1927,6 +1927,20 @@ program
}
});
program
.command("login")
.description("Alias for web:login (personal WhatsApp Web QR link)")
.option("--verbose", "Verbose connection logs", false)
.action(async (opts) => {
setVerbose(Boolean(opts.verbose));
try {
await loginWeb(Boolean(opts.verbose));
} catch (err) {
defaultRuntime.error(danger(`Web login failed: ${String(err)}`));
defaultRuntime.exit(1);
}
});
program
.command("send")
.description("Send a WhatsApp message")