mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { LocalJSXCommandOnDone, LocalJSXCommandContext } from '../../types/command.js';
|
|
|
|
/**
|
|
* /job slash command — manages template jobs from inside the REPL.
|
|
*
|
|
* Subcommands: list | new <template> [args] | reply <id> <text> | status <id>
|
|
* Default (no args): list
|
|
*/
|
|
export async function call(
|
|
onDone: LocalJSXCommandOnDone,
|
|
_context: LocalJSXCommandContext,
|
|
args: string,
|
|
): Promise<React.ReactNode> {
|
|
const parts = args ? args.trim().split(/\s+/) : [];
|
|
const sub = parts[0] || 'list';
|
|
|
|
// Capture console output so we can return it as onDone text
|
|
const lines: string[] = [];
|
|
const origLog = console.log;
|
|
const origError = console.error;
|
|
console.log = (...a: unknown[]) => lines.push(a.map(String).join(' '));
|
|
console.error = (...a: unknown[]) => lines.push(a.map(String).join(' '));
|
|
|
|
try {
|
|
const { templatesMain } = await import('../../cli/handlers/templateJobs.js');
|
|
await templatesMain([sub, ...parts.slice(1)]);
|
|
} finally {
|
|
console.log = origLog;
|
|
console.error = origError;
|
|
}
|
|
|
|
onDone(lines.join('\n') || 'Done.', { display: 'system' });
|
|
return null;
|
|
}
|