switchboard turns a JSON description of switches into an interactive checkbox list.
Flipping a switch runs the on or off command from your switchboard.yaml configuration.
With Homebrew:
brew install foundry23/tap/switchboardOr with Go:
go install github.com/foundry23/switchboard@latestswitchboard spec.json # from a file
some-generator | switchboard # from stdin (keyboard input falls back to /dev/tty)
switchboard "$(some-generator)" # from a command substitution — stdin stays the keyboard| Flag | Env var | Default | Purpose |
|---|---|---|---|
--config |
SWITCHBOARD_CONFIG |
auto-detected | path to the switch spec YAML |
--shell |
SWITCHBOARD_SHELL |
sh |
shell every command runs under, as <shell> -c <command> |
When --config is not given, switchboard looks for switchboard.yaml, switchboard.yml, .switchboard.yaml, or .switchboard.yml in the current directory.
All keys are case-insensitive.
| Key | Action |
|---|---|
↑/↓ or j/k |
move between items |
space / enter |
toggle the selected item |
r |
re-check the state of all items |
? |
show a legend of every command |
q / esc / ctrl+c |
quit (press twice) |
There are 2 separate specs that are involved in the setup of Switchboard: the list of items, and the switch commands.
The recommended best practice is to store the switch spec in a switchboard.yaml file in your project, and to pass the list of items dynamically by piping the list through.
{
"title": "Preview environments",
"items": [
{ "label": "myapp PR-123", "description": "https://pr-123.myapp.localhost", "args": { "ticket": "pr-123" } },
{ "label": "myapp PR-124", "args": { "ticket": "pr-124" } }
]
}| Field | Required | Purpose |
|---|---|---|
title |
heading shown above the list | |
items[].label |
✓ | text shown next to the checkbox |
items[].description |
dimmed text after the label | |
items[].args |
named values for the config's {{ .name }} templates |
There are currently 3 commands that switchboard handles, and they are all required.
switch:
on: git worktree add ../{{ .ticket }} {{ .ticket }}
off: git worktree remove ../{{ .ticket }}
check: git worktree list | grep -q {{ .ticket }}switch.on/switch.off— Runs when the item is toggled on or off.switch.check— Ran on initialisation, and will determine the default state of the switch. Can be re-ran withr.Exit 0means on and any other exit code meansoff.
just build # go build -o switchboard .
just fmt # goimports + gofumpt
just check # go vet + go testjust --list shows every recipe. CI runs build, vet, race tests, formatting, and linting (golangci-lint).
Contributions are welcome:
- Open an issue first for anything non-trivial so the approach can be agreed before you build it.
- Fork and branch, and add tests where it makes sense.
- Run
just checkbefore opening a PR. - Keep commits focused and the CI green.
AI-assisted contributions are welcome, but code must be reviewed by a human before being submitted.
Any contributions that have not obviously been reviewed by a human may be closed without comment or justification.
MIT.