feat: save hosts file

This commit is contained in:
Philip Henning 2025-08-14 10:09:30 +02:00
parent e59af1cb02
commit e813704f81
6 changed files with 60 additions and 23 deletions

View file

@ -1,6 +1,10 @@
package tui
import (
"fmt"
"hosts-go/internal/core"
tea "github.com/charmbracelet/bubbletea"
)
@ -24,6 +28,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} else {
m.mode = ViewMode
}
case "ctrl+s":
if m.mode == EditMode && m.hostsPath != "" {
if err := core.WriteHostsFile(m.hostsPath, m.hosts); err != nil {
fmt.Println("save failed:", err)
}
}
case " ":
if m.mode == EditMode {
if entry := m.SelectedEntry(); entry != nil {