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)
| 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: |
no test coverage detected