Expand description
Utilities for parsing command line arguments
entrance
provides type assisted tools for parsing command line argumuments.
§Usage
use entrance::*;
use std::path::PathBuf;
#[derive(Options)]
enum Opts {
#[entrance(description = "Print the help message")]
#[entrance(short = 'h')]
#[entrance(informative(entrance::help))]
Help,
#[entrance(description = "Use verbose output")]
#[entrance(short = 'v')]
Verbose,
}
#[derive(Arguments)]
struct Args {
#[entrance(description = "Path to a file")]
path: PathBuf,
}
let args = ["program", "-v", "path/to/file"].iter().map(|s| s.to_string());
// Parse only options to exit immediately with "--version" or "--help".
let command = Command::<Opts, Args>::new("program", "1.0.0");
let (opts, args) = command.parse(args).unwrap();
assert!(!opts.is_empty());
assert_eq!(args.path, PathBuf::from("path/to/file"));
Structs§
- Helper struct for parsing command line arguments.
- Helper struct for printing help messages with
format!
and{}
.
Enums§
Traits§
- A trait for parsing and containing arguments.
- A trait for parsing and containing options.
Functions§
- A callback function to print help messages
- A helper function to parse argument
- A callback function to print the version