Skip to content

Commit

Permalink
Prevent losing commands orders when adding the 'help' command.
Browse files Browse the repository at this point in the history
When adding the 'help' command (by using the 'add_help_cmd' parameter),
the command was added to the exising configuration and then commands were
sorted. Now, the command is added before the other commands and so the
order of commands is kept.
  • Loading branch information
fmenabe committed Jun 23, 2017
1 parent e59c6e3 commit 8396042
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,11 @@ def __init__(self, config, keyword='command', deepcopy=True):
raise CLGError([], 'unable to add help command: no subparsers')

if 'parsers' in subparsers_conf:
subparsers_conf['parsers'].update(_HELP_PARSER)
subparsers_conf['parsers'] = (
OrderedDict(sorted(subparsers_conf['parsers'].items())))
subparsers_conf['parsers'] = OrderedDict(
list(_HELP_PARSER.items()) + list(subparsers_conf['parsers'].items()))
else:
subparsers_conf.update(_HELP_PARSER)
subparsers_conf = OrderedDict(sorted(subparsers_conf.items()))
subparsers_conf = OrderedDict(
list(_HELP_PARSER.items()) + list(subparsers_conf.items()))
self.config['subparsers'] = subparsers_conf

self._add_parser([])
Expand Down

0 comments on commit 8396042

Please sign in to comment.