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:
[]
= "1.6.1"
After adding the dependency, you can import the modules you need in your Rust code. For example:
use ;
use ;
Examples
Reading User Input
use input;
// Read user input as a string
let user_input: String = input;
println!;
Selecting Options
Single Option
use select;
let options = ;
// Allow the user to select one option
let selected_index = select;
println!;
Multiple Options
use multiselect;
let options = ;
// Allow the user to select multiple options
let selected_indices = multiselect;
println!;
Console Control
use ;
// Flush the output buffer to ensure content is displayed immediately
flush;
// Clear the current line in the console
clear_line;
// and more...
// Consult the docs for more details!
Reading Key
use ;
// Cross-platform key reading
let key = read_key;
println!;
Displaying a Spinner
use ;
// Display a standard spinner for 3 seconds
spinner;
// Display a custom spinner for 2 seconds
spinner;
Gradual String Reveal
use reveal;
// Display "Hello World!" with a time interval of 0.1 seconds between each character
reveal;
For more detailed documentation, please refer to the generated Rust Docs.