Skip to main content

Module pick

Module pick 

Source
Expand description

Interactive fallbacks for arguments the user did not pass.

The rule across the CLI: on a terminal a missing identifier opens a picker, and everywhere else the command fails exactly as it did before, so scripts and CI keep their old behaviour. A picker is a convenience for the human at the keyboard, never a new way for an unattended run to hang.

Every picker here calls ensure_interactive first, for the reason spelled out in crate::libs::prompt: dialoguer reads stdin unconditionally and would otherwise block forever, or read EOF and report an empty answer as if the user had chosen nothing.

The labels matter as much as the list. Picking an issue by key alone means reading PROJ-4471 and guessing; the labels here carry the same summary, badge and duration the list views show, so the choice is made on what the row means rather than on its identifier.

§Usage

use kasl::libs::pick;
use kasl::db::jira_inbox::JiraInbox;

// A command with an optional KEY resolves it like this.
let key = match None::<String> {
    Some(key) => key,
    None => pick::inbox_issue(&JiraInbox::new()?.list_active(false)?, "Pick an issue")?,
};

Functions§

inbox_issue
Picks an inbox issue, showing what each one is rather than just its key.
pause
Picks a pause, showing when it started and how long it lasted.
tag
Picks a tag by name, showing its colour where one is set.
tasks
Picks one or more tasks, showing name and completeness.