Skip to content

Commit

Permalink
Prevent alphabetical sorting of commands in help
Browse files Browse the repository at this point in the history
  • Loading branch information
psss committed Oct 7, 2019
1 parent d27da39 commit 9b32552
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tmt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@
# Shared metadata tree
tree = None


class KeepOrderGroup(click.Group):
""" Custom group to prevent alphabetical sorting """
def list_commands(self, context):
return self.commands.keys()

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Main
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@click.group()
@click.group(cls=KeepOrderGroup)
@click.option(
'--path', metavar='PATH',
default='.', show_default=True,
Expand All @@ -41,7 +47,7 @@ def main(path):
# Run
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@click.group(chain=True, invoke_without_command=True)
@click.group(chain=True, invoke_without_command=True, cls=KeepOrderGroup)
@click.pass_context
def run(context):
""" Run test steps. """
Expand Down Expand Up @@ -103,7 +109,7 @@ def finish():
# Test
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@click.group()
@click.group(cls=KeepOrderGroup)
def test():
"""
Manage tests (L1 metadata).
Expand Down Expand Up @@ -175,7 +181,7 @@ def convert(paths, makefile, nitrate, purpose):
# Testset
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@click.group()
@click.group(cls=KeepOrderGroup)
def testset():
"""
Manage testsets (L2 metadata).
Expand Down Expand Up @@ -211,7 +217,7 @@ def show(names):
# Story
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@click.group()
@click.group(cls=KeepOrderGroup)
def story():
"""
Manage user stories.
Expand Down

0 comments on commit 9b32552

Please sign in to comment.