Conversation
| TerminalProgram string `help:"Terminal program this command is running in which can influence 'auto' editor" env:"TERM_PROGRAM" hidden:""` | ||
| TerminalEmulator string `help:"Terminal emulator can influence 'auto' editor" env:"TERMINAL_EMULATOR" hidden:""` |
There was a problem hiding this comment.
Yehhh just reading envars to determine if the user is inside VSCode or IntelliJ terminals. Each editor indicates it in different ways. Got a better idea?
There was a problem hiding this comment.
Ah I see. There's no good solution to this AFAIK, but I think this would be better if it was in a dedicated "editor" package that could detect the user's editor, or have it configured.
|
I also don't know if we should call this "open"... as a user I would expect that to open the console. Maybe "ftl edit" would be better? |
| if i.Editor == autodetect { | ||
| if i.TerminalProgram == "vscode" { | ||
| i.Editor = vscode | ||
| } else if strings.Contains(i.TerminalEmulator, "JetBrains") { | ||
| i.Editor = intellij | ||
| } else { | ||
| return errors.Errorf("could not auto choose default editor, expected one of %s", strings.Join([]string{vscode, intellij}, ", ")) | ||
| } | ||
| } |
There was a problem hiding this comment.
Yeah can we pull this out into a dedicated package and make it extensible instead?
There was a problem hiding this comment.
Or maybe just move this into the user's config?
It's very difficult and non-cross-platform to open an editor automatically, so maybe we just punt on it...
For example, this won't work for me at all as I don't use vscode or JetBrains.
There was a problem hiding this comment.
Yeh puntings easiest
|
Wes ended up finishing this off in other branches 🏆 |
ftl open <ref> <editor>IDEs:
vscodeintellijEditor is autodetected within vscode and intellij terminals.
TODO:
open->edit