16 use command::{available_commands, Command, help::Help};
17 use configuration::Configuration;
19 fn main() -> Result<()> {
22 if cfg!(debug_assertions) {
29 std::process::exit(1);
35 fn run() -> Result<()> {
36 let configuration = Configuration::new();
37 let commands = available_commands();
38 let arguments: Vec<String> = args().collect();
40 if let Some(command_name) = arguments.get(1) {
41 if let Some(main_command) = commands.into_iter().find(|c| c.command() == command_name) {
42 let before_commands = main_command.before_dependencies();
43 let after_commands = main_command.after_dependencies();
45 let command_chain: Vec<Box<dyn Command>> = before_commands
47 .chain(once(main_command))
48 .chain(after_commands.into_iter())
51 for command in command_chain {
52 let result = command.execute(arguments.get(2), &configuration, command_name);
53 if let Err(_) = result {
62 Help::new().execute(None, &configuration, &"help".to_string())