diff --git a/src/cli.ts b/src/cli.ts index c8fe650..67dc353 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -20,11 +20,22 @@ program.name("sandlot").description("Branch-based development with git worktrees program .command("new") - .argument("", "branch name") + .argument("", "branch name or prompt (if it contains spaces)") .argument("[prompt]", "initial prompt for Claude") .option("-p, --print ", "run Claude in non-interactive mode with -p") .description("Create a new session and launch Claude") .action(async (branch: string, prompt: string | undefined, opts: { print?: 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 worktreeAbs = join(homedir(), '.sandlot', basename(root), branch)