import { Command } from 'commander' import { runLsCommand } from './ls.js' import { runArchiveCommand } from './archive.js' import { withOutput } from '../../output/index.js' export function createWorktreeCommand(): Command { const worktree = new Command('worktree').description('Manage Paseo-managed git worktrees') worktree .command('ls') .description('List Paseo-managed git worktrees') .option('--json', 'Output in JSON format') .option('--host ', 'Daemon host:port (default: localhost:6767)') .action((options, command) => { if (options.json) { command.parent.parent.opts().format = 'json' } return withOutput(runLsCommand)(options, command) }) worktree .command('archive') .description('Archive a worktree (removes worktree and associated branch)') .argument('', 'Worktree name or branch name') .option('--host ', 'Daemon host:port (default: localhost:6767)') .action(withOutput(runArchiveCommand)) return worktree }