Bug #4865
Non positional arguments are partially matched
Status: | Resolved | Start date: | 01/09/2014 | |
---|---|---|---|---|
Priority: | Medium | Due date: | 01/17/2014 | |
Assignee: | Stavros Sachtouris | % Done: | 100% |
|
Category: | kamaki | Spent time: | 3.00 hours | |
Target version: | v0.13 | Estimated time: | 3.00 hours |
Description
E.g. instead of --device-id a user may use --devi
This looks like argparse feature
Associated revisions
Disable argument abbreviation
Refs: #4865
Implementaton details: subclass ArgumentParser and override the
_get_option_tuples method. Replace option_string comparison
operator: == instead of .startswith
The rest of the method code is copy-pasted from python 2.7.3 argparse
History
#1 Updated by Stavros Sachtouris over 9 years ago
- Status changed from New to Closed
- Estimated time changed from 3.00 to 0.00
This behaviour is inherited from the python argparse module and it is not necessarily a bug
The ability to write --device instead of --device-id is nice, as long as there are no conflicts with other arguments
This concern is resolved by argparse which does not recognise partial arguments when they are ambiguous.
For example, the --size-min and --size-max arguments in kamaki image list can be shortened as
--size-mi --size-ma
but nothing shorter, since anything shorter would be ambiguous.
#2 Updated by Vangelis Koukis over 9 years ago
- Status changed from Closed to Assigned
Stavros,
this is certainly unwanted behavior, and bound to create problems.
Please disable this. A workaround exists here:
#3 Updated by Stavros Sachtouris over 9 years ago
- Estimated time changed from 0.00 to 3.00
Vangelis, this particular workaround seems like a bad idea: a patch on argparse which is not included in any python 2.X version may cause more problems than it solves.
There is another workaround I've found a few months ago: http://stackoverflow.com/questions/10750802/disable-abbreviation/10751356#10751356
It is based on overwriting argparse behaviour.
Maybe the solution should be based on the later rather than the former.
Btw, I quote Jonathan Paugh's response from issue14910 : "I am dubious as to the use of this: I think resolving partial args is one of the best things invented since sliced bread"
(I don't necessarily agree)
#4 Updated by Vangelis Koukis over 9 years ago
I don't have a strong opinion on the way to disable the "feature", as long as it actually gets disabled.
Do whatever you think is best.
#5 Updated by Stavros Sachtouris over 9 years ago
- Status changed from Assigned to Resolved
- % Done changed from 0 to 100