Crates.io | term-snip |
lib.rs | term-snip |
version | 0.1.8 |
source | src |
created_at | 2021-04-25 15:11:49.328835 |
updated_at | 2024-01-28 08:47:06.641052 |
description | Write limited number of lines to terminal |
homepage | |
repository | https://github.com/sorcerersr/term-snip |
max_upload_size | |
id | 389333 |
size | 20,003 |
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.
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 showing above example in action
Clearing the written lines afterwards (cargo run --example clear
)
Licensed under either of
at your option.