diff --git a/click/core.py b/click/core.py index 074152872..3acfce6cb 100644 --- a/click/core.py +++ b/click/core.py @@ -1567,8 +1567,12 @@ def _parse_decls(self, decls, expose_value): opts.append(decl) if name is None and possible_names: - possible_names.sort(key=lambda x: len(x[0])) - name = possible_names[-1][1].replace('-', '_').lower() + # From docs: By default, the name of the parameter is the first + # long option defined; otherwise the first short one + # is used. + name = ([n for d, n in possible_names if len(d) == 2] + + [n for d, n in possible_names if len(d) == 1])[0] + name = name.replace('-', '_').lower() if not isidentifier(name): name = None