Console Utils

A Rust library for console-based user input, option selection, control, and more.
Overview
This crate offers utility functions for various console-related operations in Rust programs. From obtaining user input to achieving precise terminal control, its main focus is to remain simple while providing extensive functionality.
Usage
To use Console Utils in your Rust project, you can add the following dependency to your Cargo.toml
file:
[dependencies]
console-utils = "1.5.8"
After adding the dependency, you can import the modules you need in your Rust code. For example:
use console_utils::input::{input, select};
use console_utils::control::{flush, clear_line};
Example
use console_utils::{input::{input, spinner, SpinnerType, select, reveal}, control::clear_line};
fn main() {
let user_input: Option<String> = input("Enter something: ", false);
match user_input {
Some(value) => println!("You entered: {}", value),
None => panic!("Input cannot be None when 'allow_empty' is set to false."),
}
spinner(3.0, SpinnerType::Standard);
let key = read_key();
println!("Pressed key: {:?}", key);
let options = vec![
"Option 1",
"Option 2",
"Option 3",
];
let selected_indices = select("Select an option:", &options, false, false);
match selected_indices {
Some(indices) => println!("Selected indices: {:?}", indices),
None => panic!("The Options cannot be None, allow_empty is false."),
}
reveal("Hello World!", 0.1);
clear_line();
}
For more detailed documentation, please refer to the generated Rust Docs.