Arguably — Quickstart Tutorial

Imagine we're building a utility for joining MP3 files, something like MP3cat. We want the user to supply the file names as a list of command line arguments. We also want to support an --out/-o option so the user can specify an output filename and a --quiet/-q flag for turning down the program's verbosity.

let mut parser = ArgParser::new()
    .helptext("Usage: mp3cat...")
    .flag("quiet q")
    .option("out o", "output.mp3");

That's it, we're done specifying our interface. Now we can parse the program's arguments:

if let Err(err) = parser.parse() {

This will exit with a suitable error message for the user if something goes wrong. Now we can recover our filenames from the parser:

for filename in parser.args {

We can also check if the --quiet flag was found:

if parser.found("quiet") {

And determine our output filepath:

let filepath = parser.value("out");