Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,52 @@ Interactive apps use `deck.Model` as the session tea root. Pass the scope with
themes/keys/views before `deck.Run`. Full contract:
[`deck/INTERFACE.md`](deck/INTERFACE.md).

### Inline CLI workflows

`deck.Inline` provides sequential setup/onboarding panels without entering a
full-screen deck session. Each panel replaces the previous panel on an ANSI
terminal; redirected streams, `TERM=dumb`, and `Plain: true` keep an append-only
transcript. No step numbers or application-specific checks are imposed.

```go
func setup(ctx context.Context) error {
flow := deck.NewInline(deck.InlineSpec{
Input: os.Stdin, Output: os.Stdout, UI: ui.Default(),
})
if err := flow.Panel("Workspace", "Choose a local directory."); err != nil {
return err
}
path, err := flow.Ask(ctx, "Workspace", "Directory", ".")
if err != nil {
return flow.Report(err) // stays inside the current panel
}
if path == "" {
return flow.Report(errors.New("a directory is required"))
}
return flow.Panel("Ready", "Directory: "+path)
}
```

A matching `Ask` retains the preceding panel's instructions alongside its text
field and key hints. Defaults can be edited with typing, backspace, and clear;
scoped key bindings drive both dispatch and hints. Cancel returns
`deck.ErrCancelled`. Text responses are visible, not password prompts. Caller
strings are treated as text, with terminal controls stripped; redact secrets
before reporting errors.

`Report` preserves error identity (`errors.Is`/`errors.As`) and marks successfully
rendered errors. At the CLI boundary, use `deck.ErrorReported(err)` to suppress
duplicate stderr output **without** suppressing a failing exit status. A render
failure returns both errors and does not mark them reported.

Call `flow.Release()` before any external command or other output. Pass
`flow.Reader()` to a child command's stdin: it preserves scripted bytes already
buffered by an earlier `Ask`. Never write concurrently or nest an `Inline` inside
a running deck. A width change preserves the previous view as transcript rather
than risking erasure of unrelated reflowed scrollback. Interactive prompts honor
context cancellation; generic line readers can only check it before/after reads.
See the executable `ExampleInline` and terminal tests in `deck/inline*_test.go`.

## Status

API may still shift before a published `v1`.
Expand Down
23 changes: 23 additions & 0 deletions deck/INTERFACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| `Content` / `Text` | Domain-agnostic job body (apps adapt before crossing) |
| `Job` + `Work.Collect` / `Work.RunInteractive` | A set of concurrent jobs: errgroup headless + tea progressive UI |
| `Confirm` | Yes/no tea prompt |
| `Inline` / `InlineSpec` | Sequential CLI panels, inline text prompts, reported errors, transcript fallback |
| `Menu` / `Message` / `Scroll` | Generic views (optional; apps may roll their own) |
| `ItemList` | Lazy Fetch+Bind selectable list (domain → `list.Item` in Bind) |
| `HomeShell` | Dual-pane menu + optional side list (Fetch+Bind; no app domain types) |
Expand Down Expand Up @@ -41,6 +42,28 @@ There is no process-global active theme or scheme.
Overlays and plugins must not invent a second tea root — register Views/themes
and let the host `Model` own the program.

## Standalone CLI workflows

`Prompt`, `Confirm`, and `Inline.Ask` are standalone prompt hosts, not deck
Views. They may own a short-lived tea program **outside** a deck session, never
nested within `Model`. `Inline` stays in normal scrollback and replaces only its
owned region; it never uses the alternate screen. `Panel` and `Report` are
synchronous writes, and each `Ask` relinquishes raw mode before returning.

Apps supply domain checks and sequencing through normal Go control flow; no
setup commands, paths, service names, or step counts belong in the library.
`InlineSpec.UI` carries the rendering scope. The default text-safe key map is
derived from that scope, with `InlineClear` bound to ctrl+u; an explicit
`InlineSpec.Keys` replaces it. Input dispatch and hints share the same map.

Only ANSI-capable input/output terminal pairs replace views. Plain, dumb, or
redirected streams retain transcripts without ANSI, with a shared buffered input
reader for successive prompts. `Release` must precede external writes;
`Reader` hands buffered input to child processes. Callers own validation,
secret redaction, and exit policy; `Report`/`ErrorReported` preserve error
identity while avoiding duplicate error messages. The API is sequential, not
concurrency-safe. Terminal-width changes preserve earlier reflowed output.

## Chrome contract

Apps inject branding via `WithChrome(Chrome{Brand, BrandGlyph, Subtitle, ClockGlyph})`.
Expand Down
Loading
Loading