Commit bf5338b3 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Revert "cli: Disable abbreviation matching for options"

This reverts commit 232aab3f

. We
shouldn't change the parsing of command line options in the middle of
the 2.5.x series.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 431f2a80
......@@ -29,7 +29,6 @@ import time
import logging
import errno
import itertools
import optparse
from cStringIO import StringIO
from ganeti import utils
......@@ -44,7 +43,7 @@ from ganeti import compat
from ganeti import netutils
from ganeti import qlang
from optparse import (TitledHelpFormatter,
from optparse import (OptionParser, TitledHelpFormatter,
Option, OptionValueError)
......@@ -1334,10 +1333,10 @@ def _ParseArgs(argv, commands, aliases):
cmd = aliases[cmd]
func, args_def, parser_opts, usage, description = commands[cmd]
parser = CustomOptionParser(option_list=parser_opts + COMMON_OPTS,
description=description,
formatter=TitledHelpFormatter(),
usage="%%prog %s %s" % (cmd, usage))
parser = OptionParser(option_list=parser_opts + COMMON_OPTS,
description=description,
formatter=TitledHelpFormatter(),
usage="%%prog %s %s" % (cmd, usage))
parser.disable_interspersed_args()
options, args = parser.parse_args()
......@@ -1347,21 +1346,6 @@ def _ParseArgs(argv, commands, aliases):
return func, options, args
class CustomOptionParser(optparse.OptionParser):
def _match_long_opt(self, opt):
"""Override C{OptionParser}'s function for matching long options.
The default implementation does prefix-based abbreviation matching. We
disable such behaviour as it can can lead to confusing conflicts (e.g.
C{--force} and C{--force-multi}).
"""
if opt in self._long_opt:
return opt
else:
raise optparse.BadOptionError(opt)
def _CheckArguments(cmd, args_def, args):
"""Verifies the arguments using the argument definition.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment