Trait goldenscript::Runner
source · pub trait Runner {
// Required method
fn run(&mut self, command: &Command) -> Result<String, Box<dyn Error>>;
// Provided methods
fn start_script(&mut self) -> Result<(), Box<dyn Error>> { ... }
fn end_script(&mut self) -> Result<(), Box<dyn Error>> { ... }
fn start_block(&mut self) -> Result<String, Box<dyn Error>> { ... }
fn end_block(&mut self) -> Result<String, Box<dyn Error>> { ... }
fn start_command(
&mut self,
command: &Command
) -> Result<String, Box<dyn Error>> { ... }
fn end_command(
&mut self,
command: &Command
) -> Result<String, Box<dyn Error>> { ... }
}Expand description
Runs goldenscript commands, returning their output.
Required Methods§
sourcefn run(&mut self, command: &Command) -> Result<String, Box<dyn Error>>
fn run(&mut self, command: &Command) -> Result<String, Box<dyn Error>>
Runs a goldenscript command, returning its output, or an error if the command fails.
Arguments can be accessed directly via Command::args, or by using
the Command::consume_args helper for more convenient processing.
Error cases are typically tested by running the command with a !
prefix (expecting a failure), but the runner can also handle these
itself and return an Ok result with appropriate output.
Provided Methods§
sourcefn start_script(&mut self) -> Result<(), Box<dyn Error>>
fn start_script(&mut self) -> Result<(), Box<dyn Error>>
Called at the start of a goldenscript. Used e.g. for initial setup. Can’t return output, since it’s not called in the context of a block.
sourcefn end_script(&mut self) -> Result<(), Box<dyn Error>>
fn end_script(&mut self) -> Result<(), Box<dyn Error>>
Called at the end of a goldenscript. Used e.g. for state assertions. Can’t return output, since it’s not called in the context of a block.
sourcefn start_block(&mut self) -> Result<String, Box<dyn Error>>
fn start_block(&mut self) -> Result<String, Box<dyn Error>>
Called at the start of a block. Used e.g. to output initial state. Any output is prepended to the block’s output.
sourcefn end_block(&mut self) -> Result<String, Box<dyn Error>>
fn end_block(&mut self) -> Result<String, Box<dyn Error>>
Called at the end of a block. Used e.g. to output final state. Any output is appended to the block’s output.