mirror of https://github.com/cheat/cheat.git
Bug fix on the last commit.
This commit is contained in:
parent
ba4093620a
commit
5e17da0246
18
cheat
18
cheat
|
@ -53,10 +53,8 @@ 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
|
|
||||||
# are given
|
|
||||||
if 'EDITOR' not in os.environ:
|
if 'EDITOR' not in os.environ:
|
||||||
print('In order to use "create" or "edit" you must set your '
|
print('In order to use "create" or "edit" you must set your '
|
||||||
'EDITOR environment variable to your favorite editor\'s path')
|
'EDITOR environment variable to your favorite editor\'s path')
|
||||||
|
@ -66,6 +64,13 @@ def edit_cheatsheet(cheat, cheatsheets):
|
||||||
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