aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: cb258c277f8257e684f48f64cb6c9a8b947d4927 (plain)
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
// mod argument_parser;
mod configuration;
mod command;

use std::env::args;
use std::io::Result;
use configuration::Configuration;
use command::{available_commands, Command, help::Help};

fn main() -> Result<()> {
    let configuration = Configuration::new();
    let commands = available_commands();

    println!("CONFIGURATION DIRECTORY: {}", configuration.config_directory.display());
    println!("DATA DIRECTORY: {}", configuration.data_directory.display());
    println!("OUTPUT DIRECTORY: {}", configuration.output_directory.display());

    let arguments: Vec<String> = args().collect();

    if let Some(command_name) = arguments.get(1) {
        if let Some(command) = commands.iter().find(|&c| c.command() == command_name) {
            return command.execute(arguments.get(2));
        }
    }

    Help::new().execute(None)
}