Crates.io | parmacl |
lib.rs | parmacl |
version | 0.1.0 |
source | src |
created_at | 2022-10-05 03:51:58.237207 |
updated_at | 2022-10-05 03:51:58.237207 |
description | A command line text parser. Parses a full command line string which has not already been pre-parsed into arguments by a shell. |
homepage | https://github.com/parmacl/parmacl |
repository | https://github.com/parmacl/parmacl |
max_upload_size | |
id | 680285 |
size | 164,381 |
A command line parser for Rust
The primary purpose of this library is to parse a full command line. That is, a string containing the complete command line.
It can also parse rust environment command line arguments as supplied by Rust (std::env::Args
) however there are other libraries which
specialise in this and may be a better choice.
While the Rust standard library does not give access to the full environment command line, this library could be used to parse internal commands entered within an application.
The main items in this library are:
Parser
- The object which parses a command line. It has properties which are set according to the style of a
command line and a list of matchers which are used to identify command line arguments.Matcher
- Each argument must be matched against a matcher. Typically one matcher is created for each argument however
matchers can also be used to match multiple arguments.Arg
- An enum with 3 variants: Binary, Param, Option. The Parser’s parse functions return an array of these
variants - each of which identify an argument the parser found in the command line.Follow the steps below to parse a command line:
Parser
.Matcher
for all possible arguments to the parser. Tag each matcher with the appropriate enum.Parser::parse_line(command_line)
which will parse the command line and return a result containing
either a vector of Arg
or an error.Arg
.