[−][src]Crate entrance
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
Arg | |
Command | Helper struct for parsing command line arguments. |
HelpDisplay | Helper struct for printing help messages with |
Opt |
Enums
Error |
Traits
Arguments | A trait for parsing and containing arguments. |
Options | A trait for parsing and containing options. |
Functions
help | A callback function to print help messages |
parse_argument | A helper function to parse argument |
parse_variable_argument | |
version | A callback function to print the version |
Type Definitions
Result |
Derive Macros
Arguments | |
Options |