Crates.io | console-utilities |
lib.rs | console-utilities |
version | 1.0.1 |
source | src |
created_at | 2024-06-04 03:31:36.543868 |
updated_at | 2024-06-06 04:38:17.326682 |
description | A Rust crate for handling console input and output utilities. |
homepage | https://github.com/suffixsec/ConsoleUtils-rs |
repository | https://github.com/suffixsec/ConsoleUtils-rs |
max_upload_size | |
id | 1260662 |
size | 8,541 |
A Rust crate for handling console input and output utilities.
[dependencies]
console-utilities = "1"
Once you have the dependency you can import it in your project:
use console_utilities::{
input::{
input,
input_rgb
},
output::{
print_rgb,
print_gradient
}
};
use console_utilities::{
input::{
input,
input_rgb,
input_gradient
},
color::RGB
};
// Prompt for user input
let user_input: String = input("Enter your name: ");
// Prompt for user input (colored)
let colored_user_input: String = input_rgb("Enter your age: ", RGB::new(255, 0, 255));
// Prompt for user input (gradient)
let gradient_user_input: String = input_gradient("Enter your favourite color: ", RGB::new(255, 255, 255) /* start color */, RGB::new(2, 2, 2) /* end color */);
println!("Name: {}\n Age: {}\n Favourite Color: {}", user_input, colored_user_input, gradient_user_input);
use console_utilities::output::{print_rgb, print_gradient};
use console_utilities::color::RGB;
// Print text in a specific color
print_rgb("This is colored text!", RGB::new(0, 255, 0));
// Print text with a gradient
print_gradient("Gradient Text", RGB::new(255, 0, 0), RGB::new(0, 0, 255));
use console_utilities::color::{RGB, set_text_color, reset_text_color};
// Define a custom RGB variable
let color_variable: RGB = RGB::new(255, 0, 255);
// Set text color
set_text_color(RGB::new(255, 0, 0));
println!("This text is red!");
println!("This text is still red!");
// Reset text color
reset_text_color();
use console_utilities::cursor::{Visibility, Move};
// Show and hide cursor
Visibility::show_cursor();
Visibility::hide_cursor();
// Move cursor
Move::cursor_up(2);
Move::cursor_down(2);
Move::cursor_left(2);
Move::cursor_right(2);
use console_utilities::console::{flush_console, clear_line, clear_lines};
// Flush the console
flush_console();
// Clear the current line
clear_line();
// Clear multiple lines
clear_lines(3);