ssm-browse: added structed log view
This commit is contained in:
parent
9752bb41bc
commit
b3d0fbfe29
11 changed files with 546 additions and 0 deletions
51
cmd/slog-view/main.go
Normal file
51
cmd/slog-view/main.go
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/lmika/awstools/internal/common/ui/commandctrl"
|
||||
"github.com/lmika/awstools/internal/common/ui/logging"
|
||||
"github.com/lmika/awstools/internal/slog-view/services/logreader"
|
||||
"github.com/lmika/awstools/internal/slog-view/controllers"
|
||||
"github.com/lmika/awstools/internal/slog-view/ui"
|
||||
"github.com/lmika/gopkgs/cli"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if flag.NArg() == 0 {
|
||||
cli.Fatal("usage: slog-view LOGFILE")
|
||||
}
|
||||
|
||||
// Pre-determine if layout has dark background. This prevents calls for creating a list to hang.
|
||||
lipgloss.HasDarkBackground()
|
||||
|
||||
closeFn := logging.EnableLogging()
|
||||
defer closeFn()
|
||||
|
||||
service := logreader.NewService()
|
||||
|
||||
ctrl := controllers.NewLogFileController(service, flag.Arg(0))
|
||||
|
||||
cmdController := commandctrl.NewCommandController()
|
||||
//cmdController.AddCommands(&commandctrl.CommandContext{
|
||||
// Commands: map[string]commandctrl.Command{
|
||||
// "cd": func(args []string) tea.Cmd {
|
||||
// return ctrl.ChangePrefix(args[0])
|
||||
// },
|
||||
// },
|
||||
//})
|
||||
|
||||
model := ui.NewModel(ctrl, cmdController)
|
||||
|
||||
p := tea.NewProgram(model, tea.WithAltScreen())
|
||||
|
||||
if err := p.Start(); err != nil {
|
||||
fmt.Printf("Alas, there's been an error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue