rtx-cli 2023.12.21

Polyglot runtime manager (asdf rust clone)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::io;
use std::sync::Mutex;

use dialoguer::Confirm;

static MUTEX: Mutex<()> = Mutex::new(());

pub fn confirm(message: &str) -> io::Result<bool> {
    let _lock = MUTEX.lock().unwrap(); // Prevent multiple prompts at once

    if !console::user_attended_stderr() {
        return Ok(false);
    }
    match Confirm::new().with_prompt(message).interact() {
        Ok(choice) => Ok(choice),
        Err(e) => Err(io::Error::new(io::ErrorKind::Other, e)),
    }
}