Files
lazyntfy/internal/tui/cmd.go
T
ahp 8673f1e83a feat(tui): add the lazygit-style three-pane interface
Topics, messages, and message detail in three panes, with filtering, publishing, adding topics, a raw JSON view, history restore, and open-link support.
2026-10-11 12:04:53 +03:30

37 lines
751 B
Go

package tui
import (
"context"
"os/exec"
"time"
tea "charm.land/bubbletea/v2"
"lazyntfy/internal/config"
"lazyntfy/internal/ntfy"
)
type publishDone struct{ err error }
type openDone struct{ err error }
func publishCmd(client *ntfy.Client, sub config.Sub, req ntfy.PublishRequest) tea.Cmd {
return func() tea.Msg {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
return publishDone{err: client.Publish(ctx, sub.Origin, sub.Name, sub.Auth, req)}
}
}
func openCmd(raw string) tea.Cmd {
return func() tea.Msg {
return openDone{err: openURL(raw)}
}
}
func openURL(raw string) error {
if err := validateURL(raw); err != nil {
return err
}
return exec.Command("xdg-open", raw).Start()
}