Skip to content

Commit

Permalink
Enhances CLI using font formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cuducos committed Aug 31, 2024
1 parent cc1d7c9 commit 45d359a
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 14 deletions.
103 changes: 93 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ edition = "2021"
[dependencies]
anyhow = "1.0.86"
clap = "4.5.16"
colored = "2.1.0"
rand = "0.8.5"
16 changes: 12 additions & 4 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
};

use anyhow::Result;
use colored::Colorize;

#[derive(Clone)]
pub struct Comment {
Expand Down Expand Up @@ -56,9 +57,9 @@ impl SimpleVariable {
.map(|has_punctuation| if has_punctuation { "" } else { ":" })
.unwrap_or(":");
match (&self.help, &self.default) {
(Some(h), Some(d)) => print!("{} [{}]{} ", h, d, colon),
(Some(h), Some(d)) => print!("{} {}", h, format!("[{}]{} ", d, colon).dimmed()),
(Some(h), None) => print!("{}{} ", h, colon),
(None, Some(d)) => print!("{} [{}]: ", self.name, d),
(None, Some(d)) => print!("{} {} ", self.name, format!("[{}]", d).dimmed()),
(None, None) => print!("{}: ", self.name),
};

Expand Down Expand Up @@ -175,10 +176,17 @@ impl Block {
if self.has_input_variables() {
println!(
"\n{}",
self.title.to_string().strip_prefix("# ").unwrap_or("")
self.title
.to_string()
.strip_prefix("# ")
.unwrap_or("")
.bold()
);
if let Some(desc) = &self.description {
println!("{}", desc.to_string().strip_prefix("# ").unwrap_or(""));
println!(
"{}",
desc.to_string().strip_prefix("# ").unwrap_or("").italic()
);
}
}
for variable in &mut self.variables {
Expand Down

0 comments on commit 45d359a

Please sign in to comment.