Skip to main content

sl/
config.rs

1use std::env;
2
3#[derive(Clone, Debug)]
4pub struct Config {
5    pub accident: bool,      // -a
6    pub c51: bool,          // -c
7    pub logo: bool,         // -l
8    pub flying: bool,       // -F
9}
10
11impl Config {
12    pub fn from_args() -> Self {
13        let mut config = Config {
14            accident: false,
15            c51: false,
16            logo: false,
17            flying: false,
18        };
19
20        for arg in env::args().skip(1) {
21            if arg.starts_with('-') {
22                for ch in arg.chars().skip(1) {
23                    match ch {
24                        'a' => config.accident = true,
25                        'c' => config.c51 = true,
26                        'l' => config.logo = true,
27                        'F' => config.flying = true,
28                        _ => {}
29                    }
30                }
31            }
32        }
33
34        config
35    }
36}