#shell #string #parser #command #parse #unicode-characters

comma

Shell-style command parser with support for escaping and quotations

4 releases (1 stable)

1.0.0 Aug 23, 2021
0.1.2 Aug 6, 2019
0.1.1 Aug 5, 2019
0.1.0 Aug 5, 2019

#1328 in Parser implementations

Download history 9877/week @ 2024-05-16 8986/week @ 2024-05-23 9127/week @ 2024-05-30 9742/week @ 2024-06-06 10265/week @ 2024-06-13 10853/week @ 2024-06-20 8738/week @ 2024-06-27 10135/week @ 2024-07-04 9439/week @ 2024-07-11 10358/week @ 2024-07-18 13326/week @ 2024-07-25 11956/week @ 2024-08-01 14372/week @ 2024-08-08 10889/week @ 2024-08-15 10762/week @ 2024-08-22 10676/week @ 2024-08-29

48,664 downloads per month
Used in 40 crates (7 directly)

MIT license

6KB
74 lines

comma

Crates.io docs.rs Build Status

comma splits shell-style commands, e.g. sendmsg joe "I say \"hi\" to you!", into a list of individual tokens. It correctly handles unicode characters, escape sequences, and single- or double-quoted strings.

Cargo

[dependencies]
comma = "1.0.0"

Usage

use comma::parse_command;

fn main () {
    let parsed = parse_command("sendmsg joe \"I say \\\"hi\\\" to you!\" 'but only\\ntoday'").unwrap();
    println!("Result: {:#?}", parsed); // Result: [ "sendmsg", "joe", "I say \"hi\" to you!", "but only\ntoday" ]
}

lib.rs:

comma parses command-line-style strings. See parse_command for details.

No runtime deps