Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: app clean up
  • Loading branch information
AuHau committed Feb 7, 2022
commit 0a5dceb848b5c199bef54252b0109bb273921342
16 changes: 12 additions & 4 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import (
"github.com/auhau/loggy/state"
"github.com/auhau/loggy/store"
"github.com/auhau/loggy/ui"
"io"
"os"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
)

// Option names
Expand All @@ -30,6 +28,8 @@ const (

var LONG_DESCRIPTION = fmt.Sprintf(`By default loggy reads from STDIN or you can specify file path to read the logs from specific file.

You quit the application by pressing Ctrl+C.

Configuration
-------------
All options that can be passed using CLI flags can be configured using config file or environment variables.
Expand Down Expand Up @@ -75,7 +75,7 @@ var cmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
var (
inputName string
inputStream io.Reader
inputStream *os.File
err error
)

Expand Down Expand Up @@ -128,8 +128,16 @@ var cmd = &cobra.Command{

go store.StartBuffering(inputStream, uiApp, stateStore, bufferSize)

// App runs until CtrlC is pressed which terminates the UI and continue the execution bellow.
// The tview capture the key press so SIGINT is not properly raised so not using it here.
err = uiApp.Run()
cobra.CheckErr(err)

// Clean up
err = inputStream.Close()
cobra.CheckErr(err)

os.Exit(0)
},
}

Expand Down