Add --install flag to completions command that outputs an install script
This commit is contained in:
parent
12ba2c7c82
commit
4db29e4beb
|
|
@ -161,8 +161,9 @@ registerVmCommands(program)
|
|||
|
||||
program
|
||||
.command("completions")
|
||||
.option("--install", "Output a shell script that installs the completions file")
|
||||
.description("Output fish shell completions")
|
||||
.action(() => completionsAction(program))
|
||||
.action((opts: { install?: boolean }) => completionsAction(program, opts))
|
||||
|
||||
// ── Default: show list if sessions exist, otherwise help ─────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,19 @@
|
|||
import type { Command, Option } from "commander"
|
||||
|
||||
/** Generate fish completions dynamically from the Commander program tree. */
|
||||
export function action(program: Command) {
|
||||
export function action(program: Command, opts: { install?: boolean } = {}) {
|
||||
if (opts.install) {
|
||||
const dest = "~/.config/fish/completions/sandlot.fish"
|
||||
const lines = [
|
||||
"#!/bin/sh",
|
||||
`mkdir -p ~/.config/fish/completions`,
|
||||
`sandlot completions > ${dest}`,
|
||||
`echo "Installed fish completions to ${dest}"`,
|
||||
]
|
||||
process.stdout.write(lines.join("\n") + "\n")
|
||||
return
|
||||
}
|
||||
|
||||
const lines: string[] = [
|
||||
"# Fish completions for sandlot (auto-generated)",
|
||||
"# Install: sandlot completions > ~/.config/fish/completions/sandlot.fish",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user