add --print flag to review command for non-interactive output
This commit is contained in:
parent
47dc4941b1
commit
afee01815c
15
src/cli.ts
15
src/cli.ts
|
|
@ -313,8 +313,9 @@ program
|
||||||
program
|
program
|
||||||
.command("review")
|
.command("review")
|
||||||
.argument("<branch>", "branch name")
|
.argument("<branch>", "branch name")
|
||||||
|
.option("-p, --print", "print the review to stdout instead of launching interactive mode")
|
||||||
.description("Launch an interactive grumpy code review for a branch")
|
.description("Launch an interactive grumpy code review for a branch")
|
||||||
.action(async (branch: string) => {
|
.action(async (branch: string, opts: { print?: boolean }) => {
|
||||||
const root = await git.repoRoot()
|
const root = await git.repoRoot()
|
||||||
const session = await state.getSession(root, branch)
|
const session = await state.getSession(root, branch)
|
||||||
|
|
||||||
|
|
@ -325,10 +326,18 @@ program
|
||||||
|
|
||||||
const spin = spinner("Starting container")
|
const spin = spinner("Starting container")
|
||||||
await vm.ensure((msg) => { spin.text = msg })
|
await vm.ensure((msg) => { spin.text = msg })
|
||||||
spin.succeed("Session ready")
|
|
||||||
|
|
||||||
const prompt = "You're a grumpy old senior software engineer. Take a look at the diff between this branch and main, then let me know your thoughts. My co-worker made these changes."
|
const prompt = "You're a grumpy old senior software engineer. Take a look at the diff between this branch and main, then let me know your thoughts. My co-worker made these changes."
|
||||||
await vm.claude(session.worktree, { prompt })
|
|
||||||
|
if (opts.print) {
|
||||||
|
spin.text = "Running review…"
|
||||||
|
const output = await vm.claude(session.worktree, { print: prompt })
|
||||||
|
spin.stop()
|
||||||
|
if (output) process.stdout.write(output + "\n")
|
||||||
|
} else {
|
||||||
|
spin.succeed("Session ready")
|
||||||
|
await vm.claude(session.worktree, { prompt })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// ── sandlot close <branch> ───────────────────────────────────────────
|
// ── sandlot close <branch> ───────────────────────────────────────────
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user