Expand description
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:
- It operates on
&OsStr
instead of&str
, thus allowing wider range of possible inputs. - It provides
parse_owned_arg()
method which can be specialized to avoid allocations. - It requires the implementor to provide
describe_type()
to print human-readable description. of expected input. - It requires the error type to implement
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.
Structs§
- Short
Iter - An iterator of short options.
Enums§
- Parse
ArgError - Possible error when parsing certain arguments.
- Value
Error - Error that can occur durin parsing command-line argument.
Traits§
- Arg
- A type that can be parsed.
- Parse
Arg - Defines an interface for types that can be created by parsing command-line argument.
- Parse
ArgFrom Str - Shorthand for implementing
ParseArg
for types that already implementFromStr
.
Functions§
- iter_
short - Creates an iterator of short arguments if the input is in the form
-abc
. - match_
arg - Checks whether given arg matches the
name
or begins withname=
and parses it appropriately.