Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/cli-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down Expand Up @@ -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");
}

Expand Down
14 changes: 14 additions & 0 deletions test/cli-picker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading