|
|
@@ -5,20 +5,30 @@ extern crate task2;
|
|
5
|
5
|
|
|
6
|
6
|
fn main() {
|
|
7
|
7
|
let args = env::args().collect();
|
|
8
|
|
- print_arguments(&args);
|
|
9
|
8
|
|
|
|
9
|
+ //print_arguments(&args);
|
|
10
|
10
|
//let conf = parse_arguments_simple(&args);
|
|
11
|
11
|
//let res = parse_arguments(&args);
|
|
12
|
12
|
|
|
13
|
13
|
let res = Config::new(&args);
|
|
14
|
14
|
match res {
|
|
15
|
15
|
Ok(conf) => {
|
|
16
|
|
- println!("{:?}", conf);
|
|
17
|
|
- println!("{:?}", task2::run(&conf));
|
|
|
16
|
+ println!(
|
|
|
17
|
+ "You asked me to count all '{}' in '{}'",
|
|
|
18
|
+ conf.search,
|
|
|
19
|
+ conf.line
|
|
|
20
|
+ );
|
|
|
21
|
+ let occ = task2::run(&conf);
|
|
|
22
|
+ println!("Found {} '{}' in '{}'", occ, conf.search, conf.line);
|
|
|
23
|
+ }
|
|
|
24
|
+ Err(message) => {
|
|
|
25
|
+ println!("{}", message);
|
|
|
26
|
+ process::exit(1)
|
|
18
|
27
|
}
|
|
19
|
|
- Err(_) => process::exit(1),
|
|
20
|
28
|
}
|
|
21
|
29
|
|
|
|
30
|
+
|
|
|
31
|
+
|
|
22
|
32
|
}
|
|
23
|
33
|
|
|
24
|
34
|
/*
|
|
|
@@ -78,6 +88,7 @@ fn parse_arguments_simple(args: &Vec<String>) -> Config {
|
|
78
|
88
|
/// each line
|
|
79
|
89
|
///
|
|
80
|
90
|
/// Returns nothing
|
|
|
91
|
+#[allow(dead_code)]
|
|
81
|
92
|
fn print_arguments(args: &Vec<String>) {
|
|
82
|
93
|
for s in args {
|
|
83
|
94
|
println!("args found: {}", s);
|