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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! # Tsur Args.
//! For handling terminal arguments.
use clap::{App, Arg, SubCommand};

use crate::consts;

// TODO: read dir
pub fn args() -> clap::ArgMatches<'static> {
    let res = App::new("tsur")
        .version(consts::VERSION.unwrap_or("Uknown"))
        .author(consts::AUTHOR)
        .about(consts::ABOUT)
        .subcommand(
            SubCommand::with_name("count")
                .arg(
                    Arg::with_name("count_chars")
                        .short("c")
                        .long("count-chars")
                        .takes_value(false)
                        .required(false)
                        .help("Count characters"),
                )
                .arg(
                    Arg::with_name("count_words")
                        .short("w")
                        .long("count-words")
                        .takes_value(false)
                        .required(false)
                        .help("Count words"),
                )
                .arg(
                    Arg::with_name("sort_by")
                        .short("s")
                        .long("sort-by")
                        .takes_value(true)
                        .required(false)
                        .possible_value("vasc")
                        .possible_value("vdesc")
                        .possible_value("kasc")
                        .possible_value("kdesc")
                        .default_value("vasc")
                        .help("Sort by key/value"),
                ),
        )
        .arg(
            Arg::with_name("file")
                .short("f")
                .long("file")
                .takes_value(true)
                .required(true)
                .min_values(1)
                .value_name("FILE(S)")
                .help("File(s) to read"),
        )
        .get_matches();
    res
}