Crates.io | parse_arg |
lib.rs | parse_arg |
version | 0.1.4 |
source | src |
created_at | 2018-11-05 17:53:00.819535 |
updated_at | 2019-09-08 18:53:23.844256 |
description | Traits and implementations for parsing command-line arguments. |
homepage | https://github.com/Kixunil/parse_arg |
repository | https://github.com/Kixunil/parse_arg |
max_upload_size | |
id | 94877 |
size | 28,333 |
Traits and implementations for parsing command-line arguments.
This crate provides traits and implementations for parsing command-line arguments.
The core of the crate is ParseArg
trait. It works much like FromStr
trait, but with
these differences:
&OsStr
instead of &str
, thus allowing wider range of possible inputs.parse_owned_arg()
method which can be specialized to avoid allocations.describe_type()
to print human-readable description.
of expected input.Display
in order to enable user-friendly interface.Further, the crate provides ParseArgFromStr
trait, which causes any type implementing it to
auto-implement ParseArg
trait. This is handy when implementing ParseArg
for types that
already have FromStr
implemented, so that boilerplate is reduced.
Since matching both --foo VAL
and --foo=VAL
arguments is common and it's not an easy task to
implement on top of OsStr
, due to limitation of std
, this crate also provides a function to
match and parse such arguments.
Further, since many programs support -xVAL
style parameters and short switches grouped into a
single argument, which isn't easy to achieve using OsStr
either, this crate provides a helper
for this too.
I will merge new implementations liberally, provided these conditions are met:
std
or in another crate which is added as an optional dependency.MITNFA