File size: 952 Bytes
90dd6a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
pub enum Command {
    Gui,
    Test { img_path: String },
    Train,
}

pub struct AppArgs {
    pub command: Command,
}

impl AppArgs {
    pub fn parse() -> Self {
        let args: Vec<String> = std::env::args().collect();

        if args.len() > 1 {
            match args[1].as_str() {
                "gui" => Self {
                    command: Command::Gui,
                },
                "test" => {
                    let img_path = if args.len() > 2 {
                        args[2].clone()
                    } else {
                        "test.jpg".to_string()
                    };
                    Self {
                        command: Command::Test { img_path },
                    }
                }
                _ => Self {
                    command: Command::Train,
                },
            }
        } else {
            Self {
                command: Command::Train,
            }
        }
    }
}