Hacking in some refinements.

This commit is contained in:
Chris Lane 2013-07-30 23:25:36 -04:00
parent 1188238381
commit 9681886409

24
cheat
View file

@ -1,10 +1,16 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
# Create a dictionary of cheat sheets # assemble a keyphrase out of all params passed to the script
keyphrase = ' '.join(sys.argv[1:])
# Create a dictionary of cheatsheets
cheats = { cheats = {
'find' : ''' 'find' : '''
executable perms
file not directory
directory not file
''', ''',
'git' : ''' 'git' : '''
@ -18,11 +24,7 @@ git config --global color.ui true
'ln' : ''' 'ln' : '''
To create a symlink: To create a symlink:
@todo: complete this
''', ''',
'tar' : ''' 'tar' : '''
@ -44,5 +46,13 @@ tar -cjvf /path/to/foo.tgz /path/to/foo/
} }
# Print help if requested
if keyphrase == 'help' or keyphrase == '--help' or keyphrase == '-h':
print 'Cheatsheets exist for the following keyphrases:'
for key in cheats:
print key
exit()
# Print the cheatsheet if it exists # Print the cheatsheet if it exists
print cheats[sys.argv[1]] if sys.argv[1] in cheats.keys() else 'No cheatsheet found.' print cheats[keyphrase] if keyphrase in cheats.keys() else 'No cheatsheet found.'