kevy-cli 7.0.0

kevy operations CLI: redis-cli-style REPL plus the migration toolchain (import/export/verify/diff/inspect/digest).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Questions the cluster manager asks on stdin.

use crate::rcli::send::write_out;

/// Print `prompt` and read one line; `None` at end of input.
pub(crate) fn line(prompt: &[u8]) -> Option<Vec<u8>> {
    write_out(prompt);
    let mut buf = String::new();
    match std::io::stdin().read_line(&mut buf) {
        Ok(0) | Err(_) => None,
        Ok(_) => Some(buf.trim_end_matches(['\n', '\r']).as_bytes().to_vec()),
    }
}

/// `prompt (type 'yes' to accept): `; `true` only for `yes`.
pub(crate) fn confirm(prompt: &[u8]) -> bool {
    line(&[prompt, b" (type 'yes' to accept): "].concat()).is_some_and(|l| l == b"yes")
}