From a84421ede7b393c184fc0c159777d508cedb8328 Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Tue, 14 Apr 2015 08:17:04 -0600 Subject: [PATCH] Sort the fuzzy matches Sort the fuzzy matches alphabetically: (.venv)terry@f350:~/python-openstackclient$ os help server Command "server" matches: server add security group server add volume server create server delete server image create server list server lock ... Change-Id: If6e6b6b31d78fce1f37019d486b15a9a78253c33 --- .gitignore | 4 ++++ cliff/help.py | 2 +- cliff/tests/test_help.py | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e7117ad..a4db32e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ pip-log.txt # pbr output AUTHORS ChangeLog + +# Editors +*~ +.*.swp diff --git a/cliff/help.py b/cliff/help.py index 3569ccc..a0b49e2 100644 --- a/cliff/help.py +++ b/cliff/help.py @@ -67,7 +67,7 @@ class HelpCommand(Command): if not fuzzy_matches: raise self.app.stdout.write('Command "%s" matches:\n' % cmd) - for fm in fuzzy_matches: + for fm in sorted(fuzzy_matches): self.app.stdout.write(' %s\n' % fm) return self.app_args.cmd = search_args diff --git a/cliff/tests/test_help.py b/cliff/tests/test_help.py index 19eaedc..3b44899 100644 --- a/cliff/tests/test_help.py +++ b/cliff/tests/test_help.py @@ -47,8 +47,7 @@ def test_list_matching_commands(): pass help_output = stdout.getvalue() assert 'Command "t" matches:' in help_output - assert 'two' in help_output - assert 'three' in help_output + assert 'three word command\n two words\n' in help_output def test_list_matching_commands_no_match():