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

#701 in Parser implementations

Download history 33064/week @ 2025-06-24 34896/week @ 2025-07-01 33738/week @ 2025-07-08 42844/week @ 2025-07-15 38939/week @ 2025-07-22 43166/week @ 2025-07-29 33690/week @ 2025-08-05 29890/week @ 2025-08-12 30092/week @ 2025-08-19 30877/week @ 2025-08-26 32357/week @ 2025-09-02 27925/week @ 2025-09-09 29030/week @ 2025-09-16 31477/week @ 2025-09-23 30938/week @ 2025-09-30 23119/week @ 2025-10-07

119,061 downloads per month
Used in 65 crates (8 directly)

MIT license

6KB
74 lines

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


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" ]
}

No runtime deps