30 lines
1023 B
TypeScript
30 lines
1023 B
TypeScript
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 <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('<name>', 'Worktree name or branch name')
|
|
.option('--host <host>', 'Daemon host:port (default: localhost:6767)')
|
|
.action(withOutput(runArchiveCommand))
|
|
|
|
return worktree
|
|
}
|