mattforni/args

example doesn't print args.full_usage() as expected

Opened this issue · 0 comments

Environment:

  • Linux, Manjaro XFCE rolling distribution, up to date
  • cargo 1.58.0-nightly (94ca096af 2021-10-29)

Steps used to reproduce:

  1. Browse to http://mattforni.github.io/rust/doc/args/
  2. Follow instructions, copying code directly from page.
  3. Add getopts = "0.2" to [dependencies] in Cargo.toml file.
  4. Change the various try!() statements to use the ? construction instead (for example, try!(args.parse(input); becomes args.parse(input)?;).
  5. Change match parse(&vec!("-i", "5")) { to match parse(&vec!("-i", "5", "--help")) {.
  6. Execute with cargo run.

Expected result

Run outputs:

Usage: program [-h] -i TIMES [-l NAME]

Run this program

Options:
    -h, --help          Pring the usage menu
    -i, --iter TIMES    The number of times to run this program
    -l, --log_file NAME The name of the log file

Successfully parsed args

Actual result

Run outputs:

Successfully parsed args

Notes

I realize this is trivial, but I figure you'd probably want to know about it, just in case someone might want to start off using this code as a sort of template before launching into something more elaborate or the like.

It's a simple enough fix. I'll see if I can provide a pull request for it after I finish writing this up.