1
2#[derive(Clone, Debug)]
3pub struct Config {
4 pub accident: bool, pub c51: bool, pub logo: bool, pub flying: bool, }
9
10impl Config {
11 pub fn from_args<I, T>(args: I) -> Self
12 where
13 I: IntoIterator<Item = T>,
14 T: AsRef<str>,
15 {
16 let mut config = Config {
17 accident: false,
18 c51: false,
19 logo: false,
20 flying: false,
21 };
22
23 for arg in args.into_iter() {
24 let arg_str = arg.as_ref();
25 if arg_str.starts_with('-') {
26 for ch in arg_str.chars().skip(1) {
27 match ch {
28 'a' => config.accident = true,
29 'c' => config.c51 = true,
30 'l' => config.logo = true,
31 'F' => config.flying = true,
32 _ => {}
33 }
34 }
35 }
36 }
37
38 config
39 }
40}