Skip to content

A small utility crate using https://github.com/mitsuhiko/console to write to stdout but limited to a given number if lines. The oldest line is removed when writing a new line.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

sorcerersr/term-snip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build and Tests codecov crates.io docs.rs

term-snip

Description

A small utility crate using https://crates.io/crates/console to write to stdout but limited to a given number of lines. The oldest line is removed when writing a new line.

Usage

From examples/five.rs:

use term_snip::TermSnip;

use std::{thread, time};

/// A simple example writing 15 lines to stdout but only showing
/// a maximum of five lines. 
fn main() {
    let half_sec = time::Duration::from_millis(500);
    
    let mut term = TermSnip::new(5);
    for n in 1..15 {
        term.write_line(&format!("{} - line number {}", n, n)).unwrap();
        
        // just to slow down for demonstration 
        thread::sleep(half_sec);
    }
}
 

Screenshot

Screenshot showing above example in action

Screenshot of example five.rs

Clearing the written lines afterwards (cargo run --example clear)

Screenshot of example clear.rs

License

Licensed under either of

at your option.

About

A small utility crate using https://github.com/mitsuhiko/console to write to stdout but limited to a given number if lines. The oldest line is removed when writing a new line.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages