cargo_lambda_interactive/
lib.rs1use inquire::{self, error::InquireResult};
2use is_terminal::IsTerminal;
3use std::fmt::Display;
4
5pub mod command;
6pub mod progress;
7
8pub fn is_stdin_tty() -> bool {
10 std::io::stdin().is_terminal()
11}
12
13pub fn is_stdout_tty() -> bool {
15 std::io::stdout().is_terminal()
16}
17
18pub fn choose_option<T: Display>(message: &str, options: Vec<T>) -> InquireResult<T> {
19 inquire::Select::new(message, options)
20 .with_vim_mode(true)
21 .with_help_message("↑↓ to move, press Ctrl+C to abort and exit")
22 .prompt()
23}
24
25pub fn is_user_cancellation_error(err: &InquireError) -> bool {
26 matches!(
27 err,
28 InquireError::OperationCanceled | InquireError::OperationInterrupted
29 )
30}
31
32pub use inquire::*;