parasyte / onlyargs

Only argument parsing! Nothing more.
MIT License
13 stars 2 forks source link

autogenerate version and help prints wrong name & wrong version #13

Closed kod-kristoff closed 5 months ago

kod-kristoff commented 1 year ago

Hi!

First, thanks for a great crate!

But when trying it here I noticed that checking the version returns this:

> cargo run -p onlyargs-tutorial-plain -- --version
onlyargs v0.1.2

and not as expected onlyargs-tutorial-plain v0.1.0.

If HELP isn't overriden, then --help also fails.

> cargo run -p onlyargs-tutorial-plain --release -- --help
   Compiling onlyargs-tutorial-plain v0.1.0
    Finished release [optimized] target(s) in 3.91s
     Running `target/release/onlyargs-tutorial-plain --help`
onlyargs v0.1.2
Obsessively tiny argument parsing

When using onlyargs-derive the problem only happens for --version.

parasyte commented 1 year ago

That's because the help and version text is compiled as static strings in the trait: https://github.com/parasyte/onlyargs/blob/f331a2ecea9a64830dd59d0996846bbd857baaed/src/lib.rs#L57-L72 This gives you a fallback when the implementation doesn't provide the help/version text, but it's of course incorrect.

It might be better to remove the fallback and require the impl to provide both strings.

When using onlyargs-derive the problem only happens for --version.

This was an oversight, but it's very easy to fix.