1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use clap::Parser;
use libpt_cli::args::VerbosityLevel;
use libpt_cli::{clap, printing};
use libpt_log::{debug, Logger};

/// This is the help
///
/// This is more help
#[derive(Parser, Debug)]
struct Cli {
    // already has documentation
    #[command(flatten)]
    verbosity: VerbosityLevel,

    /// texts to be echoed
    #[arg(required = true)]
    text: Vec<String>,

    /// try to be more machine readable
    #[arg(short, long)]
    machine: bool,
}

fn main() {
    let cli = Cli::parse();
    let _logger = Logger::builder()
        .max_level(cli.verbosity.level())
        .show_time(false)
        .build();

    debug!("logger initialized with level: {}", cli.verbosity.level());

    if !cli.machine {
        let text = cli.text.join(" ");
        printing::blockprint(text, console::Color::Green);
    } else {
        for text in cli.text {
            println!("{text}")
        }
    }
}