add fish shell completions command
This commit is contained in:
parent
c67c89f4f7
commit
7c5746e268
64
src/cli.ts
64
src/cli.ts
|
|
@ -737,6 +737,70 @@ vmCmd
|
||||||
console.log("✔ VM destroyed")
|
console.log("✔ VM destroyed")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ── sandlot completions ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("completions")
|
||||||
|
.description("Output fish shell completions")
|
||||||
|
.action(() => {
|
||||||
|
process.stdout.write(`# Fish completions for sandlot
|
||||||
|
# Install: sandlot completions > ~/.config/fish/completions/sandlot.fish
|
||||||
|
|
||||||
|
complete -c sandlot -f
|
||||||
|
|
||||||
|
function __sandlot_sessions
|
||||||
|
command sandlot list --json 2>/dev/null | string match -r '"branch":\\s*"[^"]+"' | string replace -r '.*"branch":\\s*"([^"]+)".*' '$1'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Subcommands
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a new -d "Create a new session and launch Claude"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a list -d "Show all active sessions"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a open -d "Re-enter an existing session"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a review -d "Launch an interactive code review"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a shell -d "Open a shell in the VM"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a close -d "Remove a worktree and clean up"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a merge -d "Merge a branch into main and close"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a save -d "Stage all changes and commit"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a diff -d "Show changes for a branch"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a show -d "Show prompt and full diff"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a log -d "Show commits not on main"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a dir -d "Print the worktree path"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a cleanup -d "Remove stale sessions"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a vm -d "Manage the sandlot VM"
|
||||||
|
complete -c sandlot -n __fish_use_subcommand -a completions -d "Output fish shell completions"
|
||||||
|
|
||||||
|
# Branch completions for commands that take a branch
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from open close merge save diff show log dir review shell" -xa "(__sandlot_sessions)"
|
||||||
|
|
||||||
|
# new
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from new" -s p -l print -d "Run Claude non-interactively" -r
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from new" -s n -l no-save -d "Skip auto-save after Claude exits"
|
||||||
|
|
||||||
|
# open
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from open" -s p -l print -d "Run Claude non-interactively" -r
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from open" -s n -l no-save -d "Skip auto-save after Claude exits"
|
||||||
|
|
||||||
|
# list
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from list" -l json -d "Output as JSON"
|
||||||
|
|
||||||
|
# close
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from close" -s f -l force -d "Close even with unsaved changes"
|
||||||
|
|
||||||
|
# review
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from review" -s p -l print -d "Print review to stdout"
|
||||||
|
|
||||||
|
# vm subcommands
|
||||||
|
set -l __sandlot_vm_subs create start shell status info stop destroy
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from \$__sandlot_vm_subs" -a create -d "Create and provision the VM"
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from \$__sandlot_vm_subs" -a start -d "Start the VM"
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from \$__sandlot_vm_subs" -a shell -d "Open a shell in the VM"
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from \$__sandlot_vm_subs" -a status -d "Show VM status"
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from \$__sandlot_vm_subs" -a info -d "Show VM system info"
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from \$__sandlot_vm_subs" -a stop -d "Stop the VM"
|
||||||
|
complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from \$__sandlot_vm_subs" -a destroy -d "Stop and delete the VM"
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
program.parseAsync().catch((err) => {
|
program.parseAsync().catch((err) => {
|
||||||
console.error(`✖ ${err.message ?? err}`)
|
console.error(`✖ ${err.message ?? err}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user