mirror of https://github.com/cheat/cheat.git
Bug fix on the last commit.
This commit is contained in:
parent
ba4093620a
commit
5e17da0246
32
cheat
32
cheat
|
@ -53,19 +53,24 @@ def cheat_files(cheat_directories):
|
||||||
def edit_cheatsheet(cheat, cheatsheets):
|
def edit_cheatsheet(cheat, cheatsheets):
|
||||||
"Creates or edits a cheatsheet"
|
"Creates or edits a cheatsheet"
|
||||||
|
|
||||||
# if the cheatsheet does not already exist, create it
|
# Assert that the EDITOR environment variable is set and that at least 3
|
||||||
if cheat not in cheatsheets:
|
# arguments have been given
|
||||||
# make sure EDITOR environment variable is set and that at least 3 arguments
|
if 'EDITOR' not in os.environ:
|
||||||
# are given
|
print('In order to use "create" or "edit" you must set your '
|
||||||
if 'EDITOR' not in os.environ:
|
'EDITOR environment variable to your favorite editor\'s path')
|
||||||
print('In order to use "create" or "edit" you must set your '
|
exit()
|
||||||
'EDITOR environment variable to your favorite editor\'s path')
|
|
||||||
exit()
|
|
||||||
|
|
||||||
elif len(sys.argv) < 3:
|
elif len(sys.argv) < 3:
|
||||||
print ('Must provide a cheatsheet to edit/create')
|
print ('Must provide a cheatsheet to edit/create')
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
# if the cheatsheet already exists, open it for editing
|
||||||
|
if cheat in cheatsheets:
|
||||||
|
subprocess.call([os.environ['EDITOR'],
|
||||||
|
os.path.join(cheatsheets[cheat], cheat)])
|
||||||
|
|
||||||
|
# otherwise, create it
|
||||||
|
else:
|
||||||
import cheatsheets as cs
|
import cheatsheets as cs
|
||||||
# Attempt to write the new cheatsheet to the user's ~/.cheat dir if it
|
# Attempt to write the new cheatsheet to the user's ~/.cheat dir if it
|
||||||
# exists. If it does not exist, attempt to create it.
|
# exists. If it does not exist, attempt to create it.
|
||||||
|
@ -79,11 +84,6 @@ def edit_cheatsheet(cheat, cheatsheets):
|
||||||
subprocess.call([os.environ['EDITOR'],
|
subprocess.call([os.environ['EDITOR'],
|
||||||
os.path.join(cs.cheat_dir, cheat)])
|
os.path.join(cs.cheat_dir, cheat)])
|
||||||
|
|
||||||
# if the cheatsheet does already exist, open it for editing
|
|
||||||
else:
|
|
||||||
subprocess.call([os.environ['EDITOR'],
|
|
||||||
os.path.join(cheatsheets[cheat], cheat)])
|
|
||||||
|
|
||||||
|
|
||||||
def help(cheatsheets):
|
def help(cheatsheets):
|
||||||
"Displays the program help"
|
"Displays the program help"
|
||||||
|
|
Loading…
Reference in New Issue