Skip to main content

parse_str

Function parse_str 

Source
pub fn parse_str(content: &str) -> Result<Vec<Box<dyn ScripttyCommand>>>
Expand description

Parse a scriptty script from a string slice and return the resulting commands.

Lines that are empty or start with # are ignored. Inline comments ( # …) are stripped while preserving # characters inside quoted strings.

§Errors

Returns an error if any line contains an unknown command, a malformed argument, or an unclosed quoted string.

§Example

use scriptty::parse_str;

let commands = parse_str("wait 500ms\ntype \"hello world\"\n").unwrap();
assert_eq!(commands.len(), 2);