On help, the 'Available keyphrases' output is now alphabetized.

This commit is contained in:
Chris Lane 2013-08-09 22:24:12 -04:00
parent 76cce9d584
commit 50b47445ad
1 changed files with 6 additions and 7 deletions

13
cheat
View File

@ -110,15 +110,14 @@ tar -cjvf /path/to/foo.tgz /path/to/foo/
} }
# print help if requested # print help if requested
# @todo: alphabetize key names if possible
if keyphrase in ['', 'help', '--help', '-h']: if keyphrase in ['', 'help', '--help', '-h']:
print 'Usage: cheat [keyphrase]' cheatsheets_sorted = cheatsheets.keys()
print 'Available keyphrases:' cheatsheets_sorted.sort()
for key in cheatsheets:
print key print "Usage: cheat [keyphrase]\n"
print "Available keyphrases:"
print "\n".join(cheatsheets_sorted)
exit() exit()
# print the cheatsheet if it exists # print the cheatsheet if it exists
# @todo: if I could get tab-completion on the cheatsheet names, that would
# be awesome
print cheatsheets[keyphrase] if keyphrase in cheatsheets.keys() else 'No cheatsheet found.' print cheatsheets[keyphrase] if keyphrase in cheatsheets.keys() else 'No cheatsheet found.'