[][src]Crate shtring

Split an input string into arguments by whitespace such that text between matching quotes is combined into a single argument. Additionally, single character escapes are supported and ignored where applicable.

let input =
    "Hello world! \"This text will be a single argument.\" 'So \"will\" this.' \\'Escaped quotes are ignored.\\'";
let output = split(input)?;
assert_eq!(
    output,
    vec![
        "Hello",
        "world!",
        "This text will be a single argument.",
        "So \"will\" this.",
        "\\'Escaped",
        "quotes",
        "are",
        "ignored.\\'",
    ]
);

The convenience function split is provided to easily turn an input string into a Vec over the parsed arguments, such that if the parser runs into an error, the parsing is aborted and that error is returned. For other cases, it is possible to create the Parser manually and iterate over the parsed arguments.

Structs

Parser

Iterator over the arguments in an input string.

Enums

Error

The possible error returned from the parser.

Functions

split

Split a given input string into arguments, returning the first encountered error, if any. There may be valid arguments after the erroneous one; if they are desired, use the Parser directly. See the crate-level documentation for an example use.