fn run(&self, verbose: bool, output: &mut impl std::io::Write) -> Result<i32, String> {
        // This system is highly recursive, so everything is done in this function for progressively less complex directives
        fn run_for_directive(
            directive: &BonesDirective,
            cmds: &HashMap<String, Bone>,
            verbose: bool,
            output: &mut impl std::io::Write,
        ) -> Result<i32, String> {
            // Get the token, which names the command we'll be running
            let command_name = &directive.0;
            // Now get the corresponding Bone if it exists
            let bone = cmds.get(command_name);
            let bone = match bone {
                Some(bone) => bone,
                None => return Err(format!("Error in executing Bones directive: subcommand '{}' not found. This is probably a typo in your Bonnie configuration.", command_name)),
            };
            // Now execute it and get the exit code (this may recursively call this function if ordered subcommands are nested, but that dcoesn't matter)
            // Bonnie treats all command cores as futures for an exit code, we don't care about any side effects (printing, server execution, etc.)
            let exit_code = bone.run(command_name, verbose, output)?;
            // Iterate over the conditions given and check if any of them match that exit code
            // We'll run the first one that does (even if more do after that)
            // TODO document the above behaviour
            let mut final_exit_code = exit_code;
            for (operator, directive) in directive.1.iter() {
                if operator.matches(&exit_code) {
                    // An operator has matched, check if it has an associated directive
                    final_exit_code = match directive {
                        // If it does, run that and get its exit code
                        Some(directive) => run_for_directive(directive, cmds, verbose, output)?,
                        // If not, return the exit code we just got above
                        None => exit_code,
                    };
                }
            }

            // All nestings have resolved to one exit code, we return it
            Ok(final_exit_code)
        }

        // Begin the recursion on this top-level directive
        // This will eventually return the exit code from the lowest level of recursion, which we return
        let exit_code = run_for_directive(&self.directive, &self.cmds, verbose, output)?;
        Ok(exit_code)
    }
// Runs a Bones command by evaluating the directive itself and calling commands in sequence recursively
// Currently, the logic of the Bones language lives here
Runs a Bones command by evaluating the directive itself and calling commands in sequence recursively
Currently, the logic of the Bones language lives here
Runs a Bones command by evaluating the directive itself and calling commands in sequence recursively Currently the logic of the Bones language lives here
fn run(&self, verbose: bool, output: &mut impl std::io::Write) -> Result<i32, String> {
        // This system is highly recursive, so everything is done in this function for progressively less complex directives
        fn run_for_directive(
            directive: &BonesDirective,
            cmds: &HashMap<String, Bone>,
            verbose: bool,
            output: &mut impl std::io::Write,
        ) -> Result<i32, String> {
            // Get the token, which names the command we'll be running
            let command_name = &directive.0;
            // Now get the corresponding Bone if it exists
            let bone = cmds.get(command_name);
            let bone = match bone {
                Some(bone) => bone,
                None => return Err(format!("Error in executing Bones directive: subcommand '{}' not found. This is probably a typo in your Bonnie configuration.", command_name)),
            };
            // Now execute it and get the exit code (this may recursively call this function if ordered subcommands are nested, but that dcoesn't matter)
            // Bonnie treats all command cores as futures for an exit code, we don't care about any side effects (printing, server execution, etc.)
            let exit_code = bone.run(command_name, verbose, output)?;
            // Iterate over the conditions given and check if any of them match that exit code
            // We'll run the first one that does (even if more do after that)
            // TODO document the above behaviour
            let mut final_exit_code = exit_code;
            for (operator, directive) in directive.1.iter() {
                if operator.matches(&exit_code) {
                    // An operator has matched, check if it has an associated directive
                    final_exit_code = match directive {
                        // If it does, run that and get its exit code
                        Some(directive) => run_for_directive(directive, cmds, verbose, output)?,
                        // If not, return the exit code we just got above
                        None => exit_code,
                    };
                }
            }
            // All nestings have resolved to one exit code, we return it
            Ok(final_exit_code)
        }
        // Begin the recursion on this top-level directive
        // This will eventually return the exit code from the lowest level of recursion, which we return
        let exit_code = run_for_directive(&self.directive, &self.cmds, verbose, output)?;
        Ok(exit_code)
    }
fn run ( & self , verbose : bool , output : & mut impl std :: io :: Write ) -> Result < i32 , String > { // This system is highly recursive, so everything is done in this function for progressively less complex directives fn run_for_directive ( directive : & BonesDirective , cmds : & HashMap < String , Bone > , verbose : bool , output : & mut impl std :: io :: Write , ) -> Result < i32 , String > { // Get the token, which names the command we'll be running let command_name = & directive . 0 ; // Now get the corresponding Bone if it exists let bone = cmds . get ( command_name ) ; let bone = match bone { Some ( bone ) => bone , None => return Err ( format ! ( " " command_name ) ) , } ; // Now execute it and get the exit code (this may recursively call this function if ordered subcommands are nested, but that dcoesn't matter) // Bonnie treats all command cores as futures for an exit code, we don't care about any side effects (printing, server execution, etc.) let exit_code = bone . run ( command_name , verbose , output ) ? ; // Iterate over the conditions given and check if any of them match that exit code // We'll run the first one that does (even if more do after that) // TODO document the above behaviour let mut final_exit_code = exit_code ; for ( operator , directive ) in directive . 1 . iter ( ) { if operator . matches ( & exit_code ) { // An operator has matched, check if it has an associated directive final_exit_code = match directive { // If it does, run that and get its exit code Some ( directive ) => run_for_directive ( directive , cmds , verbose , output ) ? , // If not, return the exit code we just got above None => exit_code , } ; } } // All nestings have resolved to one exit code, we return it Ok ( final_exit_code ) } // Begin the recursion on this top-level directive // This will eventually return the exit code from the lowest level of recursion, which we return let exit_code = run_for_directive ( & self . directive , & self . cmds , verbose , output ) ? ; Ok ( exit_code ) }
Runs a Bones command by evaluating the directive itself and calling commands in sequence recursively
Currently, the logic of the Bones language lives here
Runs a Bones command by evaluating the directive itself and calling commands in sequence recursively Currently the logic of the Bones language lives here
&self
verbose
bool
output
&mut impl std::io::Write