diff --git a/cheat b/cheat index ad69b44..8b3c900 100755 --- a/cheat +++ b/cheat @@ -4,7 +4,8 @@ import sys # assemble a keyphrase out of all params passed to the script keyphrase = ' '.join(sys.argv[1:]) -cheat_dir = os.path.expanduser('~') + '/.cheat/' +home = os.path.expanduser('~') +cheat_dir = home + '/.cheat/' # verify that the ~/.cheat directory exists if not os.path.isdir(cheat_dir): @@ -22,6 +23,16 @@ if keyphrase in ['', 'help', '--help', '-h']: print "\n".join(cheatsheets) exit() +if (len(sys.argv) > 1 and sys.argv[1] == 'add'): + if (len(sys.argv) > 2): + f = open(home + "/.cheat/" + sys.argv[2], 'a+') + f.write(' '.join(sys.argv[2:])) + f.close() + else: + print "Usage: cheat add [command with arguments]\n\n" + print "Example: cheat add curl -XPUT \"http://www.github.com\" #change request method for curl\n" + exit() + # print the cheatsheet if it exists if keyphrase in cheatsheets: with open (cheat_dir + keyphrase, 'r') as cheatsheet: