]> git.r.bdr.sh - rbdr/blog/blob - src/main.rs
cb258c277f8257e684f48f64cb6c9a8b947d4927
[rbdr/blog] / src / main.rs
1 // mod argument_parser;
2 mod configuration;
3 mod command;
4
5 use std::env::args;
6 use std::io::Result;
7 use configuration::Configuration;
8 use command::{available_commands, Command, help::Help};
9
10 fn main() -> Result<()> {
11 let configuration = Configuration::new();
12 let commands = available_commands();
13
14 println!("CONFIGURATION DIRECTORY: {}", configuration.config_directory.display());
15 println!("DATA DIRECTORY: {}", configuration.data_directory.display());
16 println!("OUTPUT DIRECTORY: {}", configuration.output_directory.display());
17
18 let arguments: Vec<String> = args().collect();
19
20 if let Some(command_name) = arguments.get(1) {
21 if let Some(command) = commands.iter().find(|&c| c.command() == command_name) {
22 return command.execute(arguments.get(2));
23 }
24 }
25
26 Help::new().execute(None)
27 }