From 10cb62fee97acd92a0369e0a8f8ea1729410ddf2 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 15 Aug 2013 18:03:58 -0400 Subject: [PATCH] Continuing to merge gbremer's work into master. --- cheat | 22 +++++++++++----------- install | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cheat b/cheat index a4d0117..3a1bc81 100755 --- a/cheat +++ b/cheat @@ -16,30 +16,30 @@ def cheat_files(cheat_directories): return cheats # assemble a keyphrase out of all params passed to the script -keyphrase = ' '.join(sys.argv[1:]) +keyphrase = ' '.join(sys.argv[1:]) cheat_dirs = cheat_directories() # verify that we have at least one cheat directory if not cheat_dirs: - print >> sys.stderr, 'The ~/.cheat directory does not exist or the CHEATPATH variable is not set.' - exit() + print >> sys.stderr, 'The ~/.cheat directory does not exist or the CHEATPATH variable is not set.' + exit() # list the files in the ~/.cheat directory cheatsheets = cheat_files(cheat_dirs) # print help if requested if keyphrase.lower() in ['', 'help', '--help', '-h']: - print "Usage: cheat [keyphrase]\n" - print "Available keyphrases:" - max_command = max([ len(x) for x in cheatsheets.keys() ]) + 3 - print '\n'.join(sorted([ '%s [%s]' % (key.ljust(max_command), value) for key, value in cheatsheets.items() ])) - exit() + print "Usage: cheat [keyphrase]\n" + print "Available keyphrases:" + max_command = max([ len(x) for x in cheatsheets.keys() ]) + 3 + print '\n'.join(sorted([ '%s [%s]' % (key.ljust(max_command), value) for key, value in cheatsheets.items() ])) + exit() # print the cheatsheet if it exists if keyphrase in cheatsheets: - with open (os.path.join(cheatsheets[keyphrase], keyphrase), 'r') as cheatsheet: - print cheatsheet.read() + with open (os.path.join(cheatsheets[keyphrase], keyphrase), 'r') as cheatsheet: + print cheatsheet.read() # if it does not, say so else: - print 'No cheatsheet found for %s.' % keyphrase + print 'No cheatsheet found for %s.' % keyphrase diff --git a/install b/install index 4d55ab8..b179e26 100755 --- a/install +++ b/install @@ -8,5 +8,5 @@ try: shutil.copytree('./.cheat', expanduser('~') + '/.cheat') print "cheat has been installed successfully." except IOError as e: - print >> sys.stderr, "This installer must be run as root." + print >> sys.stderr, e sys.exit(1)