termstatus

Crates.iotermstatus
lib.rstermstatus
version0.2.0
sourcesrc
created_at2023-05-29 14:57:46.749574
updated_at2023-05-30 18:01:26.7322
descriptionShow the status of your program.
homepage
repositoryhttps://github.com/phoenixr-codes/termstatus
max_upload_size
id877175
size16,362
Jonas (phoenixr-codes)

documentation

README

termstatus

termstatus is a tool that lets you inform the user the progress of your program by displaying the status. It looks similar to the status texts displayed by rustc or cargo.

Installation

Simply use $ cargo add termstatus or add the following dependency to your Cargo.toml:

[dependencies]
termstatus = "0.2"

Usage

Create an enum whose variants are the different status labels and derive it from TermStatus:

extern crate termstatus;
use termstatus::TermStatus;

#[allow(dead_code)]
#[derive(TermStatus)]
enum Status {
    Building,
    Built,
    Compiled,
    Compiling,
    #[style(red, bold)]
    Error,
    Finished,
    Running,
}

Display is automatically implemented for that enum and can therefore be used with println or format for example:

println!("{} foo", Status::Building);
println!("{} foo", Status::Built);
println!("{} bar", Status::Compiling);
println!("{} bar", Status::Compiled);
println!("{} build of project", Status::Finished);

The result will look as follows:

 Building foo
    Built foo
Compiling bar
 Compiled bar
 Finished build of project

Planned Features

  • use of #[default_style(on_aqua, italic)] on the derived enum

TODO

Commit count: 16

cargo fmt