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
58
59
60
61
62
63
64
65
mod check;
mod compute;
mod errors;
pub use check::check;
pub use compute::compute;

use clap::{crate_version, App, Arg};

pub fn parse_args<'a, 'b>() -> App<'a, 'b> {
    App::new("srisum")
        .version(crate_version!())
        .author("Kat Marchán <kzm@zkat.tech>")
        .about("Compute and check subresource integrity digests.")
        .arg(
            Arg::with_name("FILE")
                .multiple(true)
                .default_value("-")
                .index(1)
                .help("files to process, depending on mode"),
        )
        .arg(
            Arg::with_name("algorithms")
                .short("a")
                .long("algorithms")
                .value_name("ALGO")
                .takes_value(true)
                .multiple(true)
                .default_value("sha256")
                .help("hash algorithms to generate for the FILEs"),
        )
        .arg(
            Arg::with_name("digest-only")
                .short("d")
                .long("digest-only")
                .help("print digests only, without the filename"),
        )
        .arg(
            Arg::with_name("check")
                .short("c")
                .long("check")
                .help("read integrity checksums from the FILEs and check them"),
        )
        .arg(
            Arg::with_name("ignore-missing")
                .long("ignore-missing")
                .help("don't fail or report status for missing files"),
        )
        .arg(
            Arg::with_name("quiet")
                .short("q")
                .long("quiet")
                .help("don't print OK for each successfully verified file"),
        )
        .arg(
            Arg::with_name("status")
                .long("status")
                .help("don't output anything, status code shows success"),
        )
        .arg(
            Arg::with_name("warn")
                .short("w")
                .long("warn")
                .help("warn about improperly formatted checksum lines"),
        )
}