app: work-around abbrev
cliff does parsing in two phases: it parses the argv options with parse_known_args(), then find the command, then reparses the command line again with the parser having being enhanced by the command found. The problem is that by default, argparse uses prefix matching https://docs.python.org/3/library/argparse.html#prefix-matching and this is not possible to disable before Python 3.5. That means that: $ myapp --endpoint foobar mycommand --start 1 --end 0 is parsed as as namespace with endpoint=0 because --end is read as an abbrev for --endpoint. This is the case because --end is not registered until we recognize "mycommand" and register its parsing. This patches fixes that. Change-Id: I21f8d9ba580349d2a8fad36bb265033ef64b1278 Closes-Bug: #1503618
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"""Application base class.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import codecs
|
||||
import inspect
|
||||
import locale
|
||||
@@ -10,6 +9,7 @@ import logging.handlers
|
||||
import os
|
||||
import sys
|
||||
|
||||
from cliff import argparse
|
||||
from .complete import CompleteCommand
|
||||
from .help import HelpAction, HelpCommand
|
||||
from .utils import damerau_levenshtein, COST
|
||||
|
||||
Reference in New Issue
Block a user