#[path = "guide_support/mod.rs"]
mod guide_support;
use guide_support::Shots;
use rich::{ColorSystem, Console, Panel, Table};
fn main() {
let shots = Shots::from_args("guide_getting_started");
shots.shot("hello", 40, hello);
controlling();
capturing();
shots.shot("nesting", 40, nesting);
}
fn hello(console: &Console) {
console.print_str("[bold magenta]Hello[/] [green]World[/]");
}
fn controlling() {
let console = Console::builder()
.force_terminal(true) .color_system(Some(ColorSystem::Truecolor))
.width(80) .build();
assert_eq!(console.width(), 80);
}
fn capturing() {
let console = Console::builder()
.force_terminal(true)
.color_system(Some(ColorSystem::Truecolor))
.build();
let ansi = console.capture(|c| c.print_str("[bold]hi[/]"));
assert_eq!(ansi, "\x1b[1mhi\x1b[0m\n");
}
fn nesting(console: &Console) {
let mut table = Table::new();
table.add_column("crate");
table.add_column("imported as");
table.add_row(&["rs-rich", "[bold]rich[/]"]);
table.add_row(&["rs-rich-ext", "[bold]rich_ext[/]"]);
console.print(&Panel::fit(Box::new(table)).title("[b]Renderables nest[/]"));
}