Projects STRLCPY cfonts Commits e93052f3
🤬
  • ■ ■ ■ ■ ■ ■
    rust/src/cli.rs
    1 1  //! The contents of this module is all about cli specific functionality
    2  -use crate::color::color;
     2 +use std::env;
     3 + 
     4 +use crate::color::{color, get_term_color_support, TermColorSupport};
    3 5  use crate::config::{Align, BgColors, Colors, Env, Fonts, OptionType, Options, CLIOPTIONS};
    4 6  use crate::debug::{d, Dt};
    5 7  use crate::render::render;
    skipped 41 lines
    47 49   ..Options::default()
    48 50   });
    49 51   
     52 + let (bold_start, bold_end) = if get_term_color_support() == TermColorSupport::NoColor {
     53 + (String::from(""), String::from(""))
     54 + } else {
     55 + (String::from("\x1b[1m"), String::from("\x1b[22m"))
     56 + };
     57 + 
    50 58   output += "\n\n";
    51 59   output += &render_options.text;
    52 60   output += "\n\n";
    53 61   output += "This is a tool for sexy fonts in the console. Give your cli some love.\n";
    54 62   output += "\n";
    55 63   output += "Usage: cfonts \"<value>\" [option1] <input1> [option2] <input1>,<input2> [option3]\n";
    56  - output += "Example: \x1b[1m$ cfonts \"sexy font\" -f chrome -a center -c red,green,gray\x1b[22m\n";
     64 + output +=
     65 + &format!("Example: {}$ cfonts \"sexy font\" -f chrome -a center -c red,green,gray{}\n", bold_start, bold_end);
    57 66   output += "\n";
    58 67   output += "Options:\n";
    59 68   
    60 69   for option in CLIOPTIONS {
    61  - output += &format!("\n\x1b[1m{}, {}", option.name, option.shortcut);
     70 + output += &format!("\n{}{}, {}", bold_start, option.name, option.shortcut);
    62 71   if !option.fallback_shortcut.is_empty() {
    63 72   output += &format!(", {}", option.fallback_shortcut);
    64 73   }
    65  - output += "\x1b[22m\n";
     74 + output += &format!("{}\n", bold_end);
    66 75   output += &format!("{}\n", option.description);
    67  - output += &format!("\x1b[1m$\x1b[22m cfonts {}", option.example);
     76 + output += &format!("{}${} cfonts {}", bold_start, bold_end, option.example);
    68 77   match option.kind {
    69 78   OptionType::Font => {
    70 79   output += &color(&format!(" [ {} ]", Fonts::list()), Colors::Green).to_string();
    skipped 21 lines
Please wait...
Page is in error, reload to recover