diff --git a/src/cli-picker.ts b/src/cli-picker.ts index 8ecd3db0..44ed6305 100644 --- a/src/cli-picker.ts +++ b/src/cli-picker.ts @@ -6,7 +6,7 @@ */ import { relative, dirname, sep } from 'node:path'; import type { HostPlan, PlannedWrite } from './hosts/plan.js'; -import { brand } from './brand.js'; +import { brand, cmd } from './brand.js'; const indigo = (s: string) => `\x1b[38;2;84;111;255m${s}\x1b[0m`; const muted = (s: string) => `\x1b[38;5;244m${s}\x1b[0m`; @@ -411,19 +411,19 @@ export function formatNonInteractiveHelp(detectedIds: string[]): string { const examples: [string, string][] = [ ...(detectedIds.length > 0 ? ([ - [`graft init --agents ${detectedIds.join(" ")}`, "wire these"], - ["graft init --yes", "same, without spelling them out"], + [`${cmd("graft init")} --agents ${detectedIds.join(" ")}`, "wire these"], + [`${cmd("graft init")} --yes`, "same, without spelling them out"], ] as [string, string][]) : []), - ["graft init --agents claude", "Claude Code only"], - ["graft init --dry-run", "list every file first"], + [`${cmd("graft init")} --agents claude`, "Claude Code only"], + [`${cmd("graft init")} --dry-run`, "list every file first"], ]; - const width = Math.max(...examples.map(([cmd]) => cmd.length)); + const width = Math.max(...examples.map(([c]) => c.length)); return [ - "graft init: no TTY to prompt on, and no --agents/--yes given — nothing written.", + `${cmd("graft init")}: no TTY to prompt on, and no --agents/--yes given — nothing written.`, `detected: ${list}`, "", - ...examples.map(([cmd, note]) => ` ${cmd.padEnd(width)} # ${note}`), + ...examples.map(([c, note]) => ` ${c.padEnd(width)} # ${note}`), ].join("\n"); } diff --git a/test/cli-picker.test.ts b/test/cli-picker.test.ts index a519f5fb..0e30f10a 100644 --- a/test/cli-picker.test.ts +++ b/test/cli-picker.test.ts @@ -261,6 +261,20 @@ test('formatNonInteractiveHelp still helps when nothing was detected', () => { assert.match(text, /--agents claude/); }); +test('formatNonInteractiveHelp names the command the way it was run', () => { + const was = process.env.TRAIL_INVOKED_AS; + process.env.TRAIL_INVOKED_AS = 'trail'; + try { + const text = formatNonInteractiveHelp(['claude']); + assert.match(text, /^trail init: no TTY/); + assert.match(text, /trail init --agents claude {3}# wire these/); + assert.doesNotMatch(text, /graft/); + } finally { + if (was === undefined) delete process.env.TRAIL_INVOKED_AS; + else process.env.TRAIL_INVOKED_AS = was; + } +}); + // --- the telemetry consent row --- /** Same driver, but with the consent row offered. */