mirror of
https://github.com/cheat/cheat.git
synced 2024-11-22 05:51:35 +01:00
Cleaned up some python. Added support for subcommands.
This commit is contained in:
parent
9681886409
commit
87f1fe13b6
@ -1,2 +1,7 @@
|
|||||||
Cheat
|
Cheat
|
||||||
=====
|
=====
|
||||||
|
- overview
|
||||||
|
- obligatory xkcd
|
||||||
|
- examples
|
||||||
|
- subcommands
|
||||||
|
- help
|
||||||
|
17
cheat
17
cheat
@ -4,8 +4,8 @@ import sys
|
|||||||
# assemble a keyphrase out of all params passed to the script
|
# assemble a keyphrase out of all params passed to the script
|
||||||
keyphrase = ' '.join(sys.argv[1:])
|
keyphrase = ' '.join(sys.argv[1:])
|
||||||
|
|
||||||
# Create a dictionary of cheatsheets
|
# create a dictionary of cheatsheets
|
||||||
cheats = {
|
cheatsheets = {
|
||||||
|
|
||||||
'find' : '''
|
'find' : '''
|
||||||
executable perms
|
executable perms
|
||||||
@ -46,13 +46,12 @@ tar -cjvf /path/to/foo.tgz /path/to/foo/
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print help if requested
|
# print help if requested
|
||||||
if keyphrase == 'help' or keyphrase == '--help' or keyphrase == '-h':
|
if keyphrase in ['help', '--help', '-h']:
|
||||||
print 'Cheatsheets exist for the following keyphrases:'
|
print 'Available cheatsheets:'
|
||||||
for key in cheats:
|
for key in cheatsheets:
|
||||||
print key
|
print key
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
# print the cheatsheet if it exists
|
||||||
# Print the cheatsheet if it exists
|
print cheatsheets[keyphrase] if keyphrase in cheatsheets.keys() else 'No cheatsheet found.'
|
||||||
print cheats[keyphrase] if keyphrase in cheats.keys() else 'No cheatsheet found.'
|
|
||||||
|
Loading…
Reference in New Issue
Block a user