cli-form (0.1.1)
Published 2026-04-18 10:08:19 -07:00 by yjx
Installation
[registry]
default = "forgejo"
[registries.forgejo]
index = "sparse+ " # Sparse index
# index = " " # Git
[net]
git-fetch-with-cli = truecargo add cli-form@0.1.1About this package
Interactive inline terminal form.
cli-form
An interactive inline terminal form. Reads a form spec from stdin, renders an editable form inline in the terminal (like fzf), and writes the result as JSON or NUON to stdout.
── Create Repository ───────────────────────────
> Name: my-project
Description: A cool project
Visibility: ● public ○ private
Add README: [x]
─────────────────────────────────────────────────
↑/↓ navigate ⏎ edit Tab submit Esc cancel
Why
Sequential CLI prompts (gh repo create, npm init, etc.) are linear and destructive — once you answer question 3 you can't go back to question 1 without Ctrl+C and starting over.
cli-form shows all fields at once and lets you navigate freely before submitting.
Install
cargo install --path .
Usage
Pipe a JSON form spec to stdin:
echo '[
{"name": "repo", "type": "text", "label": "Repository name", "default": "my-project"},
{"name": "visibility", "type": "select", "label": "Visibility", "options": ["public", "private"], "default": "public"},
{"name": "readme", "type": "confirm", "label": "Add README", "default": true}
]' | cli-form --title "Create Repository"
Output (stdout):
{
"repo": "my-project",
"visibility": "public",
"readme": true
}
Field Types
| Type | Edit behavior |
|---|---|
text |
Inline readline-style editing |
select |
Left/Right to cycle through options |
multi_select |
Left/Right to move, Space to toggle |
confirm |
Space or Enter to toggle |
Form spec schema
[
{
"name": "field_key",
"type": "text | select | multi_select | confirm",
"label": "Display label",
"options": ["opt1", "opt2"],
"default": "opt1"
}
]
options is required for select and multi_select. default is optional for all types.
Navigation
Two modes, like vi:
- Browse mode (default):
↑/↓move between fields,Enterenters Edit mode,Tabsubmits,Esccancels. - Edit mode: field-specific keys (see table above).
Escreturns to Browse mode.
Options
--title <TEXT> Form title shown in the header bar (default: "Form")
--schema <FILE> Read form spec from a file instead of stdin
--format <json|nuon> Output format (default: json)
--height <N> Max terminal lines to occupy (default: field count + 2)
Exit codes
| Code | Meaning |
|---|---|
0 |
Form submitted — result on stdout |
1 |
User cancelled with Esc |
Usage from Nushell
let spec = [
{name: "repo", type: "text", label: "Repository name", default: ($env.PWD | path basename)}
{name: "visibility", type: "select", label: "Visibility", options: ["public" "private"], default: "public"}
{name: "license", type: "select", label: "License", options: ["MIT" "Apache-2.0" "GPL-3.0" "None"], default: "MIT"}
{name: "readme", type: "confirm", label: "Add README", default: true}
]
let result = $spec | to json | cli-form --title "Create Repository" | from json
gh repo create $result.repo --($result.visibility) --license $result.license
Or use --format nuon to skip the from json step:
let result = $spec | to json | cli-form --title "Create Repository" --format nuon | from nuon
Usage from Bash
result=$(cat <<'EOF' | cli-form --title "Create Repository"
[
{"name": "repo", "type": "text", "label": "Repository name", "default": "my-project"},
{"name": "visibility", "type": "select", "label": "Visibility", "options": ["public", "private"], "default": "public"}
]
EOF
)
gh repo create "$(echo "$result" | jq -r .repo)" --"$(echo "$result" | jq -r .visibility)"
Environment
| Variable | Effect |
|---|---|
NO_COLOR |
Disables all ANSI styling (no-color.org) |
Dependencies
| ID | Version |
|---|---|
| anyhow | ^1 |
| clap | ^4 |
| crossterm | ^0.29 |
| libc | ^0.2 |
| serde | ^1 |
| serde_json | ^1 |
| vim-line | ^5.5.0 |
| insta | ^1 |
| proptest | ^1 |
| tempfile | ^3 |
Details
2026-04-18 10:08:19 -07:00
Assets (1)
Versions (1)
View all
Cargo
1
45 KiB
cli-form-0.1.1.crate
45 KiB
0.1.1
2026-04-18