Created
April 30, 2021 21:35
-
-
Save hype08/e710a1c02ed717f861632b8a1d65888c to your computer and use it in GitHub Desktop.
Parsing the command line – the structopt crate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::path::PathBuf; | |
use structopt::StructOpt; | |
#[derive(StructOpt, Debug)] | |
struct Opt { | |
/// Activate verbose mode | |
#[structopt(short = "v", long = "verbose")] | |
verbose: bool, | |
/// File to generate | |
#[structopt(short = "r", long = "result", parse(from_os_str))] | |
result_file: PathBuf, | |
/// Files to process | |
#[structopt(name = "FILE", parse(from_os_str))] | |
files: Vec<PathBuf>, | |
} | |
fn main() { | |
println!("{:#?}", Opt::from_args()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment