1 // mod argument_parser;
8 use command::{available_commands, Command, help::Help};
10 fn main() -> Result<()> {
11 let commands = available_commands();
12 let arguments: Vec<String> = args().collect();
14 if let Some(command_name) = arguments.get(1) {
15 if let Some(main_command) = commands.into_iter().find(|c| c.command() == command_name) {
16 let before_commands = main_command.before_dependencies();
17 let after_commands = main_command.after_dependencies();
19 let command_chain: Vec<Box<dyn Command>> = before_commands
21 .chain(once(main_command))
22 .chain(after_commands.into_iter())
25 for command in command_chain {
26 let result = command.execute(arguments.get(2));
27 if let Err(_) = result {
36 Help::new().execute(None)