Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(update): print help for `claudish update --help` instead of updating

Jack Rudenko86dc5fd2f025
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index 0ef1d283..64355d42 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -477,7 +477,7 @@ if (isMcpMode) {
import("./auth/quota-command.js").then((m) => m.quotaCommand(quotaProviderArg));
} else if (isUpdateCommand) {
// Self-update command (checked early to work with aliases like `claudish -y update`)
- import("./update-command.js").then((m) => m.updateCommand());
+ import("./update-command.js").then((m) => m.updateCommand(args));
} else if (isInitCommand) {
// Profile setup wizard — pass --local/--global scope flag if provided
const scopeFlag = args.includes("--local")
diff --git a/packages/cli/src/update-command-help.test.ts b/packages/cli/src/update-command-help.test.ts
new file mode 100644
index 00000000..504bab99
--- /dev/null
+++ b/packages/cli/src/update-command-help.test.ts
@@ -0,0 +1,59 @@
+import { afterAll, beforeAll, expect, test } from "bun:test";
+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join, resolve } from "node:path";
+
+const isolatedHome = mkdtempSync(join(tmpdir(), "claudish-update-help-"));
+const cliPath = resolve(import.meta.dir, "index.ts");
+const configPath = join(isolatedHome, "config.json");
+
+beforeAll(() => {
+ writeFileSync(configPath, "{}");
+});
+
+afterAll(() => {
+ rmSync(isolatedHome, { recursive: true, force: true });
+});
+
+for (const flag of ["--help", "-h"]) {
+ test(`update ${flag} prints help without starting the updater`, async () => {
+ const child = Bun.spawn([process.execPath, cliPath, "update", flag], {
+ cwd: isolatedHome,
+ env: {
+ PATH: process.env.PATH,
+ HOME: isolatedHome,
+ BUN_INSTALL: isolatedHome,
+ CLAUDISH_CONFIG: configPath,
+ CLAUDISH_DISABLE_KEYCHAIN: "1",
+ CLAUDISH_DISABLE_OP: "1",
+ },
+ stdin: "ignore",
+ stdout: "pipe",
+ stderr: "pipe",
+ });
+ const timeout = setTimeout(() => child.kill(), 25_000);
+ try {
+ const [stdout, stderr, exitCode] = await Promise.all([
+ new Response(child.stdout).text(),
+ new Response(child.stderr).text(),
+ child.exited,
+ ]);
+
+ expect(exitCode, stderr).toBe(0);
+ expect(stdout).toContain("Usage: claudish update");
+ for (const message of [
+ "Updating...",
+ "Unable to fetch latest version from npm registry.",
+ "Updated successfully",
+ "Already up-to-date!",
+ ]) {
+ expect(stdout).not.toContain(message);
+ expect(stderr).not.toContain(message);
+ }
+ } finally {
+ clearTimeout(timeout);
+ child.kill();
+ await child.exited;
+ }
+ }, 30_000);
+}
diff --git a/packages/cli/src/update-command.ts b/packages/cli/src/update-command.ts
index 269a98a7..d42aded1 100644
--- a/packages/cli/src/update-command.ts
+++ b/packages/cli/src/update-command.ts
@@ -388,10 +388,27 @@ export async function performUpdate(): Promise<UpdateOutcome> {
return { status: "failed", method: installInfo.method };
}
+function printUpdateHelp(): void {
+ console.log(`Usage: claudish update
+
+Checks the npm registry for the latest claudish release and, when it is newer
+than this one, installs it with the package manager that installed this copy
+(bun, npm or Homebrew), then shows what changed.
+
+Options:
+ -h, --help Show this help and exit without checking or installing
+`);
+}
+
/**
* Main update command entry point
*/
-export async function updateCommand(): Promise<void> {
+export async function updateCommand(args: string[] = []): Promise<void> {
+ // Before anything touches the network: `update --help` once ran the update.
+ if (args.includes("--help") || args.includes("-h")) {
+ printUpdateHelp();
+ return;
+ }
refreshAnsi();
// Get current version and installation info
const currentVersion = getVersion();