1.4 KiB
1.4 KiB
Selector & provider-table usage
This project provides a small provider/table/selector flow that allows providers and cmdlets to interact via a simple, pipable API.
Key ideas
provider-tablerenders a provider result set and emits pipeline-friendly dicts for each row. Each emitted item includes_selection_args, a list of args the provider suggests for selecting that row (e.g.,['-path', '/tmp/file']).selectaccepts piped items, displays a table (Rich-based), and supports selecting rows either via-selector-interactiveprompt. Selected items are emitted for downstream cmdlets or you can use-run-cmdto invoke another cmdlet for each selected item.
Example (non-interactive):
provider-table -provider example -sample | select -select 1 | add-file -store default
What providers must implement
- An adapter that yields
ResultModelobjects (breaking API). - Optionally supply a
columnsfactory andselection_fn(seeProvider/example_provider.py).
Implementation notes
provider-tableemits dicts like{ 'title': ..., 'path': ..., 'metadata': ..., '_selection_args': [...] }.selectwill prefer_selection_argsif present; otherwise it will fall back to provider selection logic or sensible defaults (-pathor-title).
This design keeps the selector-focused UX small and predictable while enabling full cmdlet interoperability via piping and -run-cmd.