gui.editor.editor_argv(template, path, line=None)
The argument list that opens path at line.
Parameters
| template |
str |
An editor template such as "code --goto {file}:{line}". |
required |
| path |
Path | str |
The file to open. |
required |
| line |
int | None |
The 1-based line. None opens the top of the file. |
None |
Returns
|
list[str] |
list[str]: The command as an argument list, never a shell string. |
Raises
|
ValueError |
If the template is empty, has a placeholder that does not exist or cannot be split into words. |
Examples
from spotregen.gui.editor import PRESETS, editor_argv
print(editor_argv(PRESETS["code"], "/tmp/my file.toml", 7))
print(editor_argv(PRESETS["mvim"], "/tmp/my file.toml", 7))
print(editor_argv(PRESETS["vim-terminal"], "/tmp/a.toml", 3)[2])
['code', '--goto', '/tmp/my file.toml:7']
['mvim', '+7', '--', '/tmp/my file.toml']
tell application "Terminal" to do script "vim +3 -- /tmp/a.toml"