mirror of
https://github.com/Erreur32/cheat.git
synced 2024-10-31 21:11:07 +01:00
Created the -l option to list cheatsheets. I believe this is goign to be helpful to expose to scripts that are attempting to implement autocomplete.
This commit is contained in:
parent
be7bc488b0
commit
34f3eafb1a
15
cheat
15
cheat
@ -108,12 +108,16 @@ def help(cheatsheets):
|
|||||||
Available keyphrases:
|
Available keyphrases:
|
||||||
''').strip()
|
''').strip()
|
||||||
|
|
||||||
max_command = max([len(x) for x in cheatsheets.keys()]) + 3
|
print list_cheatsheets(cheatsheets)
|
||||||
print ('\n'.join(sorted(['%s [%s]' % (key.ljust(max_command), value)
|
|
||||||
for key, value in cheatsheets.items()])))
|
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
|
def list_cheatsheets(cheatsheets):
|
||||||
|
max_command = max([len(x) for x in cheatsheets.keys()]) + 3
|
||||||
|
return ('\n'.join(sorted(['%s [%s]' % (key.ljust(max_command), value)
|
||||||
|
for key, value in cheatsheets.items()])))
|
||||||
|
|
||||||
|
|
||||||
def pretty_print(filename):
|
def pretty_print(filename):
|
||||||
"Applies syntax highlighting to a cheatsheet and writes it to stdout"
|
"Applies syntax highlighting to a cheatsheet and writes it to stdout"
|
||||||
try:
|
try:
|
||||||
@ -177,6 +181,11 @@ def main():
|
|||||||
print("\n".join(cheat_directories()))
|
print("\n".join(cheat_directories()))
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
# list cheatsheets and exit
|
||||||
|
if option in ['-l', '--list']:
|
||||||
|
print list_cheatsheets(cheatsheets)
|
||||||
|
exit()
|
||||||
|
|
||||||
# print the cheatsheet if it exists
|
# print the cheatsheet if it exists
|
||||||
if keyphrase in cheatsheets:
|
if keyphrase in cheatsheets:
|
||||||
filename = os.path.join(cheatsheets[keyphrase], keyphrase)
|
filename = os.path.join(cheatsheets[keyphrase], keyphrase)
|
||||||
|
Loading…
Reference in New Issue
Block a user