mirror of
https://github.com/shokinn/hosts-go.git
synced 2025-08-23 16:43:02 +00:00
feat: save hosts file
This commit is contained in:
parent
e59af1cb02
commit
e813704f81
6 changed files with 60 additions and 23 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue