-
Notifications
You must be signed in to change notification settings - Fork 83
confusing failure mode when usage and option sections are inconsistent #226
Comments
I don't think there's any bug here, but the failure mode is obviously bad. There are two errors in your example code. Firstly, your option description section needs to indicate that a flag takes an argument. So instead of Ideas on how to improve the failure modes here would be appreciated. It seems like the least we could do is report the inconsistency between the flag definition |
Oh, sorry for mixing these things up in the example. I just assumed something's wrong with the crate because it acted weird in this case and didn't throw errors at me (like it does for the missing args). |
As outlined in this bug docopt/docopt.rs#226 Docopt is rather specific about flags versus positional arguments. In our case we had positional arguments that we where using as flags. This created some very confusing behavior where you you could reorder the flags and get a arcane looking config error because 'linux' (the platform arg) was passed as the config arg. If you look carefully at the example USAGE in the Docopt README https://github.com/docopt/docopt you see that all flags not only require the Args strut but also the use of the = sign. This patch corrects these problems and allows flags to work as expected
As outlined in this bug docopt/docopt.rs#226 Docopt is rather specific about flags versus positional arguments. In our case we had positional arguments that we where using as flags. This created some very confusing behavior where you you could reorder the flags and get a arcane looking config error because 'linux' (the platform arg) was passed as the config arg. If you look carefully at the example USAGE in the Docopt README https://github.com/docopt/docopt you see that all flags not only require the Args strut but also the use of the = sign. This patch corrects these problems and allows flags to work as expected
As outlined in this bug docopt/docopt.rs#226 Docopt is rather specific about flags versus positional arguments. In our case we had positional arguments that we where using as flags. This created some very confusing behavior where you you could reorder the flags and get a arcane looking config error because 'linux' (the platform arg) was passed as the config arg. If you look carefully at the example USAGE in the Docopt README https://github.com/docopt/docopt you see that all flags not only require the Args strut but also the use of the = sign. This patch corrects these problems and allows flags to work as expected
When the following test program is executed with
--output out --input in
arguments, the values switch places, the input variable inArgs
gets "out" and the output one gets the "in" value.I encountered this issue with 0.8.1 and the latest nightly (
rustc 1.21.0-nightly
).Test program
Result
Args { arg_input: Some("out"), arg_output: Some("in") }
Expected result
Args { arg_input: Some("in"), arg_output: Some("out") }
The text was updated successfully, but these errors were encountered: