use owo_colors::{
AnsiColors::{Green, Red, Yellow},
DynColors, OwoColorize,
};
use punfetch::info::{PercentBar, DEFAULT_BAR_WIDTH};
use punfetch::{
info::{sys, ColorBar, HostInfo},
Distro,
Printer,
Render,
};
#[derive(Render)]
struct ExampleInfo {
pub field: String,
pub field_two: String,
pub optional: Option<String>,
}
impl ExampleInfo {
pub fn new() -> Self {
Self {
field: "value".into(),
field_two: "this is another value".into(),
optional: None,
}
}
}
fn main() {
let sys = sys();
let host_info = HostInfo::new(&sys);
let mut printer = Printer::default();
let distro = Distro::search(host_info.distro.clone());
printer.with_ascii(distro.ascii(Some(true)));
printer.with_color(distro.color(Some(true)));
printer.with_info(host_info);
printer.with_info(PercentBar {
title: "Example Stats".to_string(),
total: 100.0,
items: vec![
("foo".to_string(), 50.0, 1.0),
("bar".to_string(), 25.0, 0.25),
("baz".to_string(), 13.0, 0.13),
],
colors: vec![
DynColors::Ansi(Green),
DynColors::Ansi(Yellow),
DynColors::Ansi(Red),
],
width: DEFAULT_BAR_WIDTH,
});
printer.with_info(ExampleInfo::new());
printer.with_info(ColorBar::default());
printer.render()
}