Julio Biason
4 years ago
3 changed files with 34 additions and 0 deletions
@ -0,0 +1,9 @@
|
||||
[package] |
||||
name = "cons" |
||||
version = "0.1.0" |
||||
description = "Tests and experimentations with Console" |
||||
authors = ["Julio Biason <julio.biason@pm.me>"] |
||||
edition = "2018" |
||||
|
||||
[dependencies] |
||||
console = "0.14" |
@ -0,0 +1,4 @@
|
||||
# Cons |
||||
|
||||
Tests and experimentation with the |
||||
[console](https://docs.rs/console/0.14.0/console/index.html) crate. |
@ -0,0 +1,21 @@
|
||||
use console::Style; |
||||
use console::Term; |
||||
|
||||
fn main() { |
||||
let term = Term::stdout(); |
||||
let (_rows, columns) = term.size(); |
||||
let success = Style::new().green().underlined(); |
||||
let error = Style::new().red().underlined(); |
||||
println!("Total width: {}", columns); |
||||
|
||||
println!( |
||||
"{value:>width$}", |
||||
value = success.apply_to("Some value"), |
||||
width = columns as usize |
||||
); |
||||
println!( |
||||
"{value:>width$}", |
||||
value = error.apply_to("Invalid"), |
||||
width = (columns / 2) as usize |
||||
) |
||||
} |
Loading…
Reference in new issue