Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.

feat: open cmd#4707

Closed
matt2e wants to merge 7 commits intomainfrom
matt2e/open
Closed

feat: open cmd#4707
matt2e wants to merge 7 commits intomainfrom
matt2e/open

Conversation

@matt2e
Copy link
Copy Markdown
Collaborator

@matt2e matt2e commented Feb 27, 2025

ftl open <ref> <editor>

IDEs:

  • vscode
  • intellij

Editor is autodetected within vscode and intellij terminals.

TODO:

@alecthomas alecthomas mentioned this pull request Feb 27, 2025
Comment thread cmd/ftl/main.go Outdated
Comment thread cmd/ftl/cmd_open.go Outdated
Comment on lines +25 to +26
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:""`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wut?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@matt2e matt2e marked this pull request as ready for review April 29, 2025 03:32
@matt2e matt2e requested a review from a team as a code owner April 29, 2025 03:32
@matt2e matt2e requested review from wesbillman and removed request for a team April 29, 2025 03:32
@alecthomas
Copy link
Copy Markdown
Collaborator

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?

Comment thread cmd/ftl/cmd_open.go
Comment on lines +52 to +60
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}, ", "))
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah can we pull this out into a dedicated package and make it extensible instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh puntings easiest

@matt2e matt2e marked this pull request as draft April 29, 2025 04:30
@matt2e
Copy link
Copy Markdown
Collaborator Author

matt2e commented May 2, 2025

Wes ended up finishing this off in other branches 🏆

@matt2e matt2e closed this May 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants