serde_args
Command line argument parsing with serde.
This library allows parsing command line arguments into types implementing Deserialize.
Features
- Help generation.
- ANSI color support.
- Integration with
serde_derive, including attributes like#[serde(alias)].
Usage
Basic usage of serde_args simply involves calling the from_env() function using a type implemented Deserialize. The type you provide defines your program's argument format. On success, the type is returned; on failure, a printable Error is returned.
Here is a simple example, created using serde's #[derive(Deserialize)] macro:
use Deserialize;
use PathBuf;
Running the above program with no provided arguments will display the following help output:
An example program
USAGE: serde_args.exe [options] <path>
Required Arguments:
<path>
Global Options:
-f --force
Override Options:
-h --help Display this message.
Running the program with example arguments of README.md -f will show the parsed arguments:
Args { path: "README.md", force: true }
Minimum Supported Rust Version
This crate is guaranteed to compile on stable rustc 1.74.0 and up.
License
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.