Introduce DEFAULT_CHEAT_DIR environment variable

Now ~/.cheat can be overridden
This commit is contained in:
a-sk 2013-08-29 18:20:23 +04:00
parent 437f191bf7
commit e662862b7b

4
cheat
View file

@ -3,7 +3,8 @@ import os
import sys import sys
import subprocess import subprocess
DEFAULT_CHEAT_DIR = os.path.join(os.path.expanduser('~'), '.cheat') DEFAULT_CHEAT_DIR = os.environ.get('DEFAULT_CHEAT_DIR') or \
os.path.join(os.path.expanduser('~'), '.cheat')
USE_PYGMENTS = False USE_PYGMENTS = False
# NOTE remove this check if it is confirmed to work on windows # NOTE remove this check if it is confirmed to work on windows
@ -140,6 +141,7 @@ def main():
elif option in ['-c', '--create']: elif option in ['-c', '--create']:
create_cheatsheet(' '.join(sys.argv[2:]), cheatsheets) create_cheatsheet(' '.join(sys.argv[2:]), cheatsheets)
# print the cheatsheet if it exists # print the cheatsheet if it exists
if keyphrase in cheatsheets: if keyphrase in cheatsheets:
filename = os.path.join(cheatsheets[keyphrase], keyphrase) filename = os.path.join(cheatsheets[keyphrase], keyphrase)