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
66
67
68
69
70
71
72
73
74
75
|
extern crate clap;
mod lib;
use clap::{App, Arg};
use std::process;
/// Central application entry point.
fn main() {
let matches = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.about(env!("CARGO_PKG_DESCRIPTION")) // CARGO_PKG_HOMEPAGE
.author(env!("CARGO_PKG_AUTHORS"))
.arg(Arg::with_name("cols")
.short("c")
.long("cols")
.value_name("columns")
.help("Set column length")
.takes_value(true))
.arg(Arg::with_name("len")
.short("l")
.long("len")
.value_name("len")
.help("Set <len> bytes to read")
.takes_value(true))
.arg(Arg::with_name("format")
.short("f")
.long("format")
.help("Set format of octet: Octal (o), LowerHex (x), UpperHex (X), Binary (b)")
.possible_values(&["o", "x", "X", "b"])
.takes_value(true))
.arg(Arg::with_name("INPUTFILE")
.help("Pass file path as an argument for hex dump")
.required(true)
.index(1))
.arg(Arg::with_name("v")
.short("v")
.multiple(true)
.help("Sets verbosity level"))
.arg(Arg::with_name("color")
.short("t")
.long("color")
.help("Set color tint terminal output. 0 to disable, 1 to enable")
.default_value("1")
.possible_values(&["0", "1"])
.takes_value(true))
.arg(Arg::with_name("array")
.short("a")
.long("array")
.value_name("array_format")
.help("Set source code format output: rust (r), C (c), golang (g)")
.possible_values(&["r", "c", "g"])
.takes_value(true))
.arg(Arg::with_name("func")
.short("u")
.long("func")
.value_name("func_length")
.help("Set function wave length")
.takes_value(true))
.arg(Arg::with_name("places")
.short("p")
.long("places")
.value_name("func_places")
.help("Set function wave output decimal places")
.takes_value(true))
.get_matches();
match lib::run(matches) {
Ok(_) => {
process::exit(0);
}
Err(e) => {
eprintln!("error = \"{}\"", e);
process::exit(1);
}
}
}
|