aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 4c2174d9775cf9989553c8a19f62ae48afebce48 (plain) (blame)
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
use dictionarium::*;

fn main() {
    let mut state = state::State::new();
    let args: Vec<String> = std::env::args().skip(1).collect();

    if args.len() == 0 {
        dictionarium::handle_parameter("--help", &mut state);
        std::process::exit(0);
    }

    let mut words = Vec::<String>::new();
    for word in args {
        if word.get(0..2) == Some("--") {
            dictionarium::handle_parameter(&word, &mut state);
        } else {
            words.push(word);
        }
    }

    // we accept multiple words gladly
    for word in words {
        dictionarium::handle_word(word, &state);
    }
}