Skip to content

Commit 7b07a6d

Browse files
MrFlounderclaude
andcommitted
feat(draw): add crab draw rename <id> "New Title" command
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent be4ecf3 commit 7b07a6d

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

plugins/draw/src/cli.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { startSession } from './commands/start.js';
55
import { openSession, openFile } from './commands/open.js';
66
import { listDrawSessions } from './commands/list.js';
77
import { deleteDrawSession } from './commands/delete.js';
8-
import { resolveSession, loadSession } from './storage/sessions.js';
8+
import { resolveSession, loadSession, updateSessionMeta } from './storage/sessions.js';
99

1010
function getArg(args: string[], flag: string, short?: string): string | undefined {
1111
for (let i = 0; i < args.length; i++) {
@@ -63,6 +63,7 @@ function showHelp(): void {
6363
console.log(' crab draw <session-id> --collab Reopen with sharing enabled');
6464
console.log(' crab draw open <path> Open .excalidraw file or directory');
6565
console.log(' crab draw ls List all sessions');
66+
console.log(' crab draw rename <id> "New Title" Rename a session');
6667
console.log(' crab draw delete <session-id> Delete a session');
6768
console.log('');
6869
console.log('Options:');
@@ -96,6 +97,38 @@ async function main(): Promise<void> {
9697
return;
9798
}
9899

100+
// crab draw rename <id> "New Title"
101+
if (command === 'rename' || command === 'mv') {
102+
const input = args[1];
103+
const newTitle = args[2];
104+
if (!input || !newTitle) {
105+
console.error('Usage: crab draw rename <session-id> "New Title"');
106+
process.exit(1);
107+
}
108+
const resolved = resolveSession(projectRoot, input);
109+
if (!resolved) {
110+
console.error(`Session "${input}" not found.`);
111+
process.exit(1);
112+
}
113+
if (resolved.ambiguous) {
114+
try {
115+
const chosen = await promptChoice(
116+
`"${input}" matches multiple sessions:`,
117+
projectRoot,
118+
resolved.ambiguous,
119+
);
120+
updateSessionMeta(projectRoot, chosen, { title: newTitle });
121+
console.log(`Renamed: ${chosen} → "${newTitle}"`);
122+
} catch {
123+
console.log('Cancelled.');
124+
}
125+
return;
126+
}
127+
updateSessionMeta(projectRoot, resolved.id, { title: newTitle });
128+
console.log(`Renamed: ${resolved.id} → "${newTitle}"`);
129+
return;
130+
}
131+
99132
// crab draw delete <id>
100133
if (command === 'delete' || command === 'rm') {
101134
const input = args[1];

0 commit comments

Comments
 (0)