diff --git a/src/cli.ts b/src/cli.ts index 1b01731..7494a02 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -96,28 +96,35 @@ program await vm.claude(join(root, session.worktree)) }) -// ── sandlot rm ────────────────────────────────────────────── +// ── sandlot close ─────────────────────────────────────────── + +const closeAction = async (branch: string) => { + const root = await git.repoRoot() + const session = await state.getSession(root, branch) + const worktreeRel = session?.worktree ?? `.sandlot/${branch}` + const worktreeAbs = join(root, worktreeRel) + + await git.removeWorktree(worktreeAbs, root) + console.log(`Removed worktree ${worktreeRel}/`) + + await git.deleteLocalBranch(branch, root) + console.log(`Deleted local branch ${branch}`) + + if (session) { + await state.removeSession(root, branch) + } +} program - .command("rm") + .command("close") .argument("", "branch name") .description("Remove a worktree and clean up the session") - .action(async (branch: string) => { - const root = await git.repoRoot() - const session = await state.getSession(root, branch) - const worktreeRel = session?.worktree ?? `.sandlot/${branch}` - const worktreeAbs = join(root, worktreeRel) + .action(closeAction) - await git.removeWorktree(worktreeAbs, root) - console.log(`Removed worktree ${worktreeRel}/`) - - await git.deleteLocalBranch(branch, root) - console.log(`Deleted local branch ${branch}`) - - if (session) { - await state.removeSession(root, branch) - } - }) +program + .command("rm", { hidden: true }) + .argument("", "branch name") + .action(closeAction) // ── sandlot vm ───────────────────────────────────────────────────────