1 // mod argument_parser;
10 use command::{available_commands, Command, help::Help};
11 use configuration::Configuration;
13 fn main() -> Result<()> {
14 let configuration = Configuration::new();
15 let commands = available_commands();
16 let arguments: Vec<String> = args().collect();
18 if let Some(command_name) = arguments.get(1) {
19 if let Some(main_command) = commands.into_iter().find(|c| c.command() == command_name) {
20 let before_commands = main_command.before_dependencies();
21 let after_commands = main_command.after_dependencies();
23 let command_chain: Vec<Box<dyn Command>> = before_commands
25 .chain(once(main_command))
26 .chain(after_commands.into_iter())
29 for command in command_chain {
30 let result = command.execute(arguments.get(2), &configuration, command_name);
31 if let Err(_) = result {
40 Help::new().execute(None, &configuration, &"help".to_string())