A crate to use borders on command-line apps.
Go to file
2023-11-08 19:43:08 +01:00
.idea Init 2023-11-08 19:04:59 +01:00
images Init 2023-11-08 19:04:59 +01:00
src Init 2023-11-08 19:04:59 +01:00
.gitattributes Init 2023-11-08 19:04:59 +01:00
.gitignore Init 2023-11-08 19:04:59 +01:00
Cargo.toml Made images in README load from GitLab; excluded images from Crate 2023-11-08 19:43:08 +01:00
LICENSE Init 2023-11-08 19:04:59 +01:00
README.md Made images in README load from GitLab; excluded images from Crate 2023-11-08 19:43:08 +01:00

Borderline

Borderline is a Crate to render borders to the terminal. You can place text or progress bars inside the borders. The usage is as simple as:

use borderline::LineBuilder;

// Create a line builder:
let mut lb = LineBuilder::new();

// Print the header first:
borderline::print_header("Borderline Test-Drive");

// Now, we are able to attach as many "line" as we want.
// Every line must be started with a call to `line_begin`
// and ended with a call to `line_end`:
lb.line_begin("- Loading...");

// perform other actions here...

// When ending a line, you can specify the second part
// of the line, which will be printed on the right side:
lb.line_end("done.");

// You can also print a progress bar:
lb.line_begin("- Loading many files:");

// Set up the progress bar using the total number of steps:
lb.progress_bar_setup(1_000);

// Do some work and update the progress bar:
for i in 0..1_000 {
    sleep(std::time::Duration::from_millis(50));
    lb.progress_bar_update(i);
}

// End the progress bar:
lb.progressbar_end();

// End the line and print the second text part:
lb.line_end("done.");

// At the end, we can print the closing border:
borderline::print_border();

While the progress bar is active: progressbar.png

When the program is done: done.png

In case that the given text is too long, it gets wrapped at word boundaries. When this is not possible, the text is wrapped at the given width.

Changelog

Version 1.0.0

  • Initial release