MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / run_editor

Method run_editor

cmd2/cmd2.py:5434–5447  ·  view source on GitHub ↗

Run a text editor and optionally open a file with it. :param file_path: optional path of the file to edit. Defaults to None. :raises ValueError: if self.editor is not set

(self, file_path: str | None = None)

Source from the content-addressed store, hash-verified

5432 self.run_editor(args.file_path)
5433
5434 def run_editor(self, file_path: str | None = None) -> None:
5435 """Run a text editor and optionally open a file with it.
5436
5437 :param file_path: optional path of the file to edit. Defaults to None.
5438 :raises ValueError: if self.editor is not set
5439 """
5440 if not self.editor:
5441 raise ValueError("Please use 'set editor' to specify your text editing program of choice.")
5442
5443 command = su.quote(os.path.expanduser(self.editor))
5444 if file_path:
5445 command += " " + su.quote(os.path.expanduser(file_path))
5446
5447 self.do_shell(command)
5448
5449 @property
5450 def _current_script_dir(self) -> str | None:

Callers 2

do_historyMethod · 0.95
do_editMethod · 0.95

Calls 1

do_shellMethod · 0.95

Tested by

no test coverage detected