Update CLI description, help/version options, and add version command

This commit is contained in:
Chris Wanstrath 2026-02-22 07:17:03 -08:00
parent 89eb5e382b
commit 10ebfcf754

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bun #!/usr/bin/env bun
import { Command } from "commander" import { Command, Option } from "commander"
import { yellow, reset } from "./fmt.ts"
import * as git from "./git.ts" import * as git from "./git.ts"
import * as state from "./state.ts" import * as state from "./state.ts"
import { action as newAction } from "./commands/new.ts" import { action as newAction } from "./commands/new.ts"
@ -25,7 +26,18 @@ const pkg = await Bun.file(new URL("../package.json", import.meta.url)).json()
const program = new Command() const program = new Command()
program.name("sandlot").description("Branch-based development with git worktrees and Apple Container").version(pkg.version) program
.name("sandlot")
.description("Sandboxed development with Claude.")
.configureHelp({ styleTitle: (str) => `${yellow}${str}${reset}` })
.helpOption(false)
.addOption(new Option("-h, --help").hideHelp())
.on("option:help", () => program.help())
.addOption(new Option("-V, --version").hideHelp())
.on("option:version", () => {
console.log(pkg.version)
process.exit(0)
})
// ── Sessions ──────────────────────────────────────────────────────── // ── Sessions ────────────────────────────────────────────────────────
@ -50,7 +62,7 @@ program
.argument("[prompt]", "initial prompt for Claude") .argument("[prompt]", "initial prompt for Claude")
.option("-p, --print <prompt>", "run Claude in non-interactive mode with -p") .option("-p, --print <prompt>", "run Claude in non-interactive mode with -p")
.option("-n, --no-save", "skip auto-save after Claude exits") .option("-n, --no-save", "skip auto-save after Claude exits")
.description("Re-enter an existing session") .description("Open an existing Claude session")
.action(openAction) .action(openAction)
program program
@ -144,6 +156,13 @@ program
registerVmCommands(program) registerVmCommands(program)
program
.command("version")
.description("Print the version number")
.action(() => {
console.log(pkg.version)
})
program program
.command("completions") .command("completions")
.option("--install", "Output a shell script that installs the completions file") .option("--install", "Output a shell script that installs the completions file")