aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: e31b384d4fa9b4cd9812f9b428258c964d840a3f (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
26
use std::env;
use dictionarium;

fn main() {
    let mut state = dictionarium::State::new();
    let args: Vec<String> = 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);
    }
}