Skip to main content

split_status

Function split_status 

Source
pub fn split_status(text: &str) -> (&str, Option<&str>)
Expand description

Splits a shell call’s output (ShellRun::output) into what the command printed, each line with its \n, and the line after it saying how the command ended; text whole and None when it does not end in such a line. A command’s own output never ends the text, so a line it printed that reads like one is kept as printed.

use rig_tools::split_status;

assert_eq!(split_status("built\n[exit code 0]"), ("built\n", Some("[exit code 0]")));
assert_eq!(split_status("no status\n"), ("no status\n", None));