move main

Signed-off-by: Hadi <[email protected]>
This commit is contained in:
Hadi
2026-08-23 17:12:34 +02:00
parent 4199b6aa7f
commit 032397e1fd
4 changed files with 5 additions and 55 deletions
View File
+5
View File
@@ -21,6 +21,11 @@ func main() {
os.Exit(1)
}
if _, err := guard.ListDevices(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
p := tea.NewProgram(newApp())
if _, err := p.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
-11
View File
@@ -50,7 +50,6 @@ type Model struct {
rulesManaged bool
rulesWritable bool
pendingRules []pendingRule
fatalShown bool
ModalOpen bool
}
@@ -172,16 +171,6 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
case actionMsg:
if msg.err != nil {
if msg.err == guard.ErrPermission {
if m.fatalShown {
return m, nil
}
m.fatalShown = true
return m, modal.Show("Permission Error", newPermissionModal(),
modal.WithModalStyle(permissionModalStyle()))
}
return m, errorToast(msg.err)
}
return m, fetchDevices
-44
View File
@@ -1,44 +0,0 @@
package ui
import (
"strings"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"github.com/anotherhadi/ilovetui/app"
"github.com/anotherhadi/ilovetui/modal"
"github.com/anotherhadi/ilovetui/style"
)
type permissionModal struct{}
func newPermissionModal() tea.Model { return permissionModal{} }
func permissionModalStyle() modal.Styles {
s := modal.DefaultStyles()
s.Title = s.Title.Foreground(style.S.Error)
s.Border = s.Border.BorderForeground(style.S.Error)
return s
}
func (permissionModal) Init() tea.Cmd { return nil }
func (m permissionModal) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case tea.KeyPressMsg, tea.MouseClickMsg:
return m, app.Quit()
}
return m, nil
}
func (permissionModal) View() tea.View {
textStyle := lipgloss.NewStyle().Foreground(style.S.Text)
hintStyle := lipgloss.NewStyle().Foreground(style.S.Muted)
parts := []string{
textStyle.Render("Can't reach the usbguard daemon (permission denied)."),
textStyle.Render("Join the usbguard group, or use sudo."),
hintStyle.Render("press any key to quit"),
}
return tea.NewView(strings.Join(parts, "\n"))
}