blyxxyz / lexopt

Minimalist pedantic command line parser
MIT License
294 stars 9 forks source link

Incorrect "missing argument at end of command" error #11

Closed blyxxyz closed 2 years ago

blyxxyz commented 2 years ago

This code:

fn main() -> Result<(), lexopt::Error> {
    let mut parser = lexopt::Parser::from_env();
    parser.values()?;
    Ok(())
}

Has this behavior:

$ cargo run -- -a b
Error: missing argument at end of command

This is Error::MissingValue's message if Parser doesn't remember an option. In 0.1.0 it was only returned by Parser::value(), at the end of the command line, but Parser::values() may return it if it encounters an option.

An easy fix would be to remove "at end of command" from the message, but maybe there's a better way out.

blyxxyz commented 2 years ago

A reasonable program would only cause a MissingValue after seeing an option, in which case this version of the message isn't used. So removing "at end of command" doesn't do much harm.

Fixed in 614d714c55b1df958fa476ada5f5729974341a1c.