mirror of
https://github.com/Erreur32/cheat.git
synced 2024-11-16 08:58:35 +01:00
23 lines
686 B
Python
Executable file
23 lines
686 B
Python
Executable file
#!/usr/bin/env python
|
|
from os.path import expanduser
|
|
import imp
|
|
import sys
|
|
|
|
# assemble a keyphrase out of all params passed to the script
|
|
keyphrase = ' '.join(sys.argv[1:])
|
|
|
|
# load the dictionary of cheatsheets
|
|
config = imp.load_source('config', expanduser('~') + '/.cheat');
|
|
|
|
# print help if requested
|
|
if keyphrase in ['', 'help', '--help', '-h']:
|
|
cheatsheets_sorted = config.cheatsheets.keys()
|
|
cheatsheets_sorted.sort()
|
|
|
|
print "Usage: cheat [keyphrase]\n"
|
|
print "Available keyphrases:"
|
|
print "\n".join(cheatsheets_sorted)
|
|
exit()
|
|
|
|
# print the cheatsheet if it exists
|
|
print config.cheatsheets[keyphrase] if keyphrase in config.cheatsheets.keys() else 'No cheatsheet found.'
|