# declared in the base class.)
boolean_options = ()
+ #: Option aliases, to retain standalone command compatibility.
+ #: Distutils does not support option aliases, but optparse does.
+ #: This maps the distutils argument name to an iterable of aliases
+ #: that are usable with optparse.
+ option_aliases = {}
+
#: Log object. To allow replacement in the script command line runner.
log = distutils_log
]
as_args = 'input-paths'
multiple_value_options = ('add-comments', 'keywords')
+ option_aliases = {
+ 'keywords': ('--keyword',),
+ 'mapping-file': ('--mapping',),
+ 'output-file': ('--output',),
+ 'strip-comments': ('--strip-comment-tags',),
+ }
def initialize_options(self):
self.charset = 'utf-8'
strs = ["--%s" % name]
if short:
strs.append("-%s" % short)
+ strs.extend(cmdclass.option_aliases.get(name, ()))
if name == as_args:
parser.usage += "<%s>" % name
elif name in cmdclass.boolean_options:
@pytest.mark.parametrize("split", (False, True))
-def test_extract_keyword_args_384(split):
+@pytest.mark.parametrize("arg_name", ("-k", "--keyword", "--keywords"))
+def test_extract_keyword_args_384(split, arg_name):
# This is a regression test for https://github.com/python-babel/babel/issues/384
+ # and it also tests that the rest of the forgotten aliases/shorthands implied by
+ # https://github.com/python-babel/babel/issues/390 are re-remembered (or rather
+ # that the mechanism for remembering them again works).
kwarg_specs = [
"gettext_noop",
]
if split: # Generate a command line with multiple -ks
- kwarg_text = " ".join("-k %s" % kwarg_spec for kwarg_spec in kwarg_specs)
+ kwarg_text = " ".join("%s %s" % (arg_name, kwarg_spec) for kwarg_spec in kwarg_specs)
else: # Generate a single space-separated -k
- kwarg_text = "-k \"%s\"" % " ".join(kwarg_specs)
+ kwarg_text = "%s \"%s\"" % (arg_name, " ".join(kwarg_specs))
# (Both of those invocation styles should be equivalent, so there is no parametrization from here on out)