]> git.r.bdr.sh - rbdr/blog/blame - src/main.rs
Add logic skeleton for rust version
[rbdr/blog] / src / main.rs
CommitLineData
d620665f
RBR
1// mod argument_parser;
2mod configuration;
3mod command;
4
5use std::env::args;
6use std::io::Result;
7use configuration::Configuration;
8use command::{available_commands, Command, help::Help};
9
10fn 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}