licence_audit/picker
Interactive tri-state picker built on the etch TUI backend.
Each item is in one of three states: Allow, Deny, or Ignore.
Pressing space cycles a single item through the states; a/d/i
apply a state to every item.
Usage:
case picker.pick(“Choose licence policy:”, labels, allow, deny) { Ok(picker.Selection(allow, deny)) -> … Error(picker.Cancelled) -> … }
Types
pub type PickerError {
Cancelled
NotInteractive
}
Constructors
-
Cancelled -
NotInteractive
pub type PickerKey {
MoveUp
MoveDown
CycleCurrent
AllowAll
DenyAll
IgnoreAll
}
Constructors
-
MoveUp -
MoveDown -
CycleCurrent -
AllowAll -
DenyAll -
IgnoreAll
pub type Selection {
Selection(allow: List(String), deny: List(String))
}
Constructors
-
Selection(allow: List(String), deny: List(String))
Values
pub fn new_state(
title: String,
labels: List(String),
allow: List(String),
deny: List(String),
) -> State
pub fn pick(
title: String,
labels: List(String),
allow: List(String),
deny: List(String),
) -> Result(Selection, PickerError)
Present an interactive tri-state prompt.
titleis shown above the list.labelsare the choices in display order.- Items whose label is in
allowstart asAllow. - Items whose label is in
denystart asDeny. - Everything else (including newly discovered licences) starts as
Ignore.
Returns a Selection containing only the labels marked Allow and Deny
(ignored labels are omitted from both lists), or Cancelled on
Esc / Ctrl-C / q.
pub fn pick_with_terminal_check(
title: String,
labels: List(String),
allow: List(String),
deny: List(String),
stdin_is_tty stdin_is_tty: fn() -> Bool,
stdout_is_tty stdout_is_tty: fn() -> Bool,
) -> Result(Selection, PickerError)
pub fn state_cursor(state: State) -> Int