Skip to content

Commit

Permalink
refactor: handle the editor missing scenario with a better message
Browse files Browse the repository at this point in the history
  • Loading branch information
tecoholic committed Nov 14, 2024
1 parent 83478e8 commit d3cd4c0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tutor/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def edit(context: Context, editor: str, save: bool) -> None:
f"Missing config file at {config_file}. Have you run 'tutor local launch' yet?"
)

open_cmd = None
open_cmd = []
if editor:
open_cmd = [editor, config_file]
elif which("open"): # MacOS & linux distributions that ship `open`. eg., Ubuntu
Expand All @@ -292,6 +292,12 @@ def edit(context: Context, editor: str, save: bool) -> None:
# Calling "start" on a regular file opens it with the default editor.
# The second argument "" just means "don't give the window a custom title".
open_cmd = ["start", '""', config_file]
else:
raise exceptions.TutorError(
"Failed to find utility to launch an editor. You can specify the editor "
"using the argument -e (e.g., tutor config edit -e vim) or edit "
f"{config_file} with the editor of your choice."
)

utils.execute(*open_cmd)

Expand Down

0 comments on commit d3cd4c0

Please sign in to comment.