#split #windows #quote #words #shell #command-line-arguments

no-std winsplit

Library to split string into command line arguments mirroring CommandLineToArgV with VC++ 2008 parsing rules

1 unstable release

0.1.0 Aug 4, 2022

#860 in Command-line interface

Download history 715/week @ 2024-07-21 1053/week @ 2024-07-28 761/week @ 2024-08-04 559/week @ 2024-08-11 607/week @ 2024-08-18 676/week @ 2024-08-25 713/week @ 2024-09-01 671/week @ 2024-09-08 1046/week @ 2024-09-15 674/week @ 2024-09-22 935/week @ 2024-09-29 848/week @ 2024-10-06 1099/week @ 2024-10-13 841/week @ 2024-10-20 1714/week @ 2024-10-27 1618/week @ 2024-11-03

5,328 downloads per month
Used in 34 crates (5 directly)

MIT/Apache

24KB
275 lines

winsplit

Crates.io Docs CI

Like shell-words, but for Windows that somewhat mirrors CommandLineToArgvW, following VC++ 2008 parsing rules.

Written purely in Rust, so runs on any operating system! Windows is not a requirement!

Minimum tested Rust version is 1.56.1, but this may compile and work on earlier versions!

Installation

[Dependencies]
winsplit = "0.1"

If you want to use this without std library, this library can be compiled for use with alloc by disabling the std feature:

[Dependencies]
winsplit = { version = "0.1", default-features = false }

Usage

let args = winsplit::split(
    r#"C:\ProgramFiles\Example\example.exe --key "some value" arg1 arg2"#
);
assert_eq!(
    args, 
    &[
        r"C:\ProgramFiles\Example\example.exe",
        "--key",
        "some value",
        "arg1",
        "arg2"
    ]
);

Parsing Rules

This library follows the 2008 parsing rules for VC++ 9.9 (msvcr90.dll) that was released with Visual Studio 2008. See C/C++ parameter parsing rules for more details.

You can also check out the mirror of the rules and examples at the wiki documentation page for this repository.

Special Thanks

Goes to David Deley for documenting the complexities of the Windows parameter parsing logic and providing numerous examples found at https://daviddeley.com/autohotkey/parameters/parameters.htm.

License

This project is licensed under either of

Apache License, Version 2.0, (LICENSE-APACHE or apache-license) MIT license (LICENSE-MIT or mit-license) at your option.

No runtime deps