1 // mod argument_parser;
17 use command::{available_commands, Command, help::Help};
18 use configuration::Configuration;
20 fn main() -> Result<()> {
21 let configuration = Configuration::new();
22 let commands = available_commands();
23 let arguments: Vec<String> = args().collect();
25 if let Some(command_name) = arguments.get(1) {
26 if let Some(main_command) = commands.into_iter().find(|c| c.command() == command_name) {
27 let before_commands = main_command.before_dependencies();
28 let after_commands = main_command.after_dependencies();
30 let command_chain: Vec<Box<dyn Command>> = before_commands
32 .chain(once(main_command))
33 .chain(after_commands.into_iter())
36 for command in command_chain {
37 let result = command.execute(arguments.get(2), &configuration, command_name);
38 if let Err(_) = result {
47 Help::new().execute(None, &configuration, &"help".to_string())