Skip to main content

Module prompt

Module prompt 

Source
Expand description

The one place in this binary that may ask a person a question.

Everything else here must complete without a terminal, because an agent driving this CLI has none and a prompt hangs it with no error and nothing in a log — that is the rule no_tty_block.rs asserts, and this module is its single named exemption.

What earns the exemption is the shape of ask, not the question it happens to carry. It never blocks: with no terminal on stdin it returns None immediately, and every caller is obliged to turn that into a refusal naming the flag that supplies the answer. So the branch a source scan is really looking for — “wait forever for input that is not coming” — does not exist here, and cannot be added without deleting the first line of the function.

One question is asked today: the account name (D75). An invite that leaves the seat open is the ordinary kind, and that name is the one string about a person the op log can never withdraw, so defaulting it from $USER or the invite id would be picking it on their behalf and calling it a convenience.

§Examples

// Under `cargo test` stdin is not a terminal, so this never blocks.
assert_eq!(choir_cli::prompt::ask("ignored"), None);

Functions§

ask
Asks question on stderr and reads one non-empty line from stdin.