Skip to content

Commit

Permalink
remove the automatic lexical sorting of groups and commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoiron committed Oct 28, 2010
1 parent 3fa83ab commit 7057489
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmdparse/cmdparse.py
Expand Up @@ -84,7 +84,7 @@ def __init__(self, *args, **kwargs):
if not kwargs.has_key("usage"):
kwargs["usage"] = "%prog [options] <command> [command options]"
OptionParser.__init__(self, *args, **kwargs)

self.auto_order = kwargs.pop('auto_order', False)
self.commands = []
self.groups = {}

Expand Down Expand Up @@ -155,7 +155,8 @@ def format_command_help(self):
result = []

groups = self.groups.keys()
groups.sort()
if self.auto_order:
groups.sort()

max_cmd_length = 0
for cmd in self.commands:
Expand All @@ -164,7 +165,8 @@ def format_command_help(self):
for group in groups:
result.append("%s commands:\n" % group)
commands = self.groups[group]
commands.sort(lambda x, y: cmp(x.get_name(), y.get_name()))
if self.auto_order:
commands.sort(lambda x, y: cmp(x.get_name(), y.get_name()))

for cmd in commands:
result.append(" %s%s %s\n" % (cmd.helpstr, " "*(max_cmd_length-len(cmd.helpstr)), cmd.summary))
Expand Down

0 comments on commit 7057489

Please sign in to comment.