feat: auto-derive branch name from prompt when spaces detected
This commit is contained in:
parent
f9d52110bb
commit
b67f1c82ed
13
src/cli.ts
13
src/cli.ts
|
|
@ -20,10 +20,21 @@ program.name("sandlot").description("Branch-based development with git worktrees
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("new")
|
.command("new")
|
||||||
.argument("<branch>", "branch name")
|
.argument("<branch>", "branch name or prompt (if it contains spaces)")
|
||||||
.argument("[prompt]", "initial prompt for Claude")
|
.argument("[prompt]", "initial prompt for Claude")
|
||||||
.description("Create a new session and launch Claude")
|
.description("Create a new session and launch Claude")
|
||||||
.action(async (branch: string, prompt?: string) => {
|
.action(async (branch: string, prompt?: string) => {
|
||||||
|
// If the "branch" contains spaces, it's actually a prompt — derive the branch name
|
||||||
|
if (branch.includes(" ")) {
|
||||||
|
prompt = branch
|
||||||
|
branch = branch
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/[^a-z0-9\s-]/g, "")
|
||||||
|
.trim()
|
||||||
|
.replace(/\s+/g, "-")
|
||||||
|
.slice(0, 20)
|
||||||
|
.replace(/-$/, "")
|
||||||
|
}
|
||||||
const root = await git.repoRoot()
|
const root = await git.repoRoot()
|
||||||
const worktreeAbs = join(homedir(), '.sandlot', basename(root), branch)
|
const worktreeAbs = join(homedir(), '.sandlot', basename(root), branch)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user