From d3cd4c04d99fbc76f811e2473d2798db50b1b9aa Mon Sep 17 00:00:00 2001 From: Arunmozhi Date: Thu, 14 Nov 2024 13:30:58 +1100 Subject: [PATCH] refactor: handle the editor missing scenario with a better message --- tutor/commands/config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tutor/commands/config.py b/tutor/commands/config.py index 75021330fa..56d99b5427 100644 --- a/tutor/commands/config.py +++ b/tutor/commands/config.py @@ -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 @@ -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)