remove config type
This commit is contained in:
parent
a506bdcd10
commit
5244285add
|
@ -4,17 +4,20 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"ewintr.nl/emdb/client"
|
||||||
"ewintr.nl/emdb/cmd/terminal-client/tui"
|
"ewintr.nl/emdb/cmd/terminal-client/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logger := tui.NewLogger()
|
logger := tui.NewLogger()
|
||||||
|
tmdb, err := client.NewTMDB(os.Getenv("TMDB_API_KEY"))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
emdb := client.NewEMDB("https://emdb.ewintr.nl", os.Getenv("EMDB_API_KEY"))
|
||||||
|
|
||||||
p, err := tui.New(tui.Config{
|
p, err := tui.New(emdb, tmdb, logger)
|
||||||
TMDBAPIKey: os.Getenv("TMDB_API_KEY"),
|
|
||||||
EMDBAPIKey: os.Getenv("EMDB_API_KEY"),
|
|
||||||
EMDBBaseURL: "https://emdb.ewintr.nl",
|
|
||||||
}, logger)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package tui
|
|
||||||
|
|
||||||
type Config struct {
|
|
||||||
TMDBAPIKey string
|
|
||||||
EMDBAPIKey string
|
|
||||||
EMDBBaseURL string
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package tui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ewintr.nl/emdb/client"
|
"ewintr.nl/emdb/client"
|
||||||
|
"github.com/charmbracelet/bubbles/viewport"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/muesli/termenv"
|
"github.com/muesli/termenv"
|
||||||
|
@ -30,8 +31,6 @@ func NewLogger() *Logger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogMsg tea.Msg
|
|
||||||
|
|
||||||
func (l *Logger) SetProgram(p *tea.Program) {
|
func (l *Logger) SetProgram(p *tea.Program) {
|
||||||
l.p = p
|
l.p = p
|
||||||
}
|
}
|
||||||
|
@ -42,14 +41,11 @@ func (l *Logger) Log(s string) {
|
||||||
|
|
||||||
type TabSizeMsgType tea.WindowSizeMsg
|
type TabSizeMsgType tea.WindowSizeMsg
|
||||||
|
|
||||||
func New(conf Config, logger *Logger) (*tea.Program, error) {
|
func New(emdb *client.EMDB, tmdb *client.TMDB, logger *Logger) (*tea.Program, error) {
|
||||||
tmdb, err := client.NewTMDB(conf.TMDBAPIKey)
|
logViewport := viewport.New(0, 0)
|
||||||
if err != nil {
|
logViewport.KeyMap = viewport.KeyMap{}
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
emdb := client.NewEMDB(conf.EMDBBaseURL, conf.EMDBAPIKey)
|
|
||||||
m, _ := NewBaseModel(emdb, tmdb, logger)
|
|
||||||
|
|
||||||
|
m, _ := NewBaseModel(emdb, tmdb, logger)
|
||||||
p := tea.NewProgram(m, tea.WithAltScreen())
|
p := tea.NewProgram(m, tea.WithAltScreen())
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
|
|
Loading…
Reference in New Issue