Skip to content

Commit

Permalink
Bug fix pallets#793; use deterministic option name; can't rely on lis…
Browse files Browse the repository at this point in the history
…t.sort
  • Loading branch information
ericfrederich committed May 18, 2017
1 parent 6f4eb1e commit 3b36317
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions click/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3b36317

Please sign in to comment.