console-utilities

Crates.ioconsole-utilities
lib.rsconsole-utilities
version1.0.1
sourcesrc
created_at2024-06-04 03:31:36.543868
updated_at2024-06-06 04:38:17.326682
descriptionA Rust crate for handling console input and output utilities.
homepagehttps://github.com/suffixsec/ConsoleUtils-rs
repositoryhttps://github.com/suffixsec/ConsoleUtils-rs
max_upload_size
id1260662
size8,541
(suffixsec)

documentation

README

Console Utilities

crates.io crates.io docs.rs

A Rust crate for handling console input and output utilities.

Usage

[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
    }
};

Examples

User Input

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);

Console Output

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));

Color Utilities

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();

Cursor Utilties

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);

Console Utilties

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);
Commit count: 23

cargo fmt