-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.rs
35 lines (29 loc) · 782 Bytes
/
main.rs
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
use clap::Parser;
use ansi_term::{Colour,Style};
/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct MyArgs {
/// Name of the person to greet
#[arg(short, long)]
name: String,
/// Number of times to greet
#[arg(short, long, default_value_t = 1)]
count: u8,
}
fn main() {
parse_args();
coloured_and_styled();
}
fn parse_args(){
let args = MyArgs::parse();
for _ in 0..args.count {
println!("Hello {}!", args.name)
}
}
fn coloured_and_styled(){
println!("{}, {} and {}",
Colour::Yellow.paint("This is colored"),
Style::new().bold().paint("this is bold"),
Colour::Red.bold().paint("this is bold and colored"));
}