Skip to content

Commit

Permalink
added PreConfigedViddy func
Browse files Browse the repository at this point in the history
  • Loading branch information
anvial committed Jun 20, 2022
1 parent c290570 commit cb2cb60
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions viddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import (
"sync/atomic"
"time"

"github.com/adrg/xdg"
"github.com/gdamore/tcell/v2"
"github.com/moby/term"
"github.com/rivo/tview"
"github.com/spf13/viper"
)

type HistoryRow struct {
Expand Down Expand Up @@ -136,6 +138,26 @@ func NewViddy(conf *config) *Viddy {
}
}

func NewPreconfigedViddy(args []string) *Viddy {
v := viper.New()
v.SetConfigType("toml")
v.SetConfigName("viddy")
v.AddConfigPath(xdg.ConfigHome)

_ = v.ReadInConfig()

conf, err := NewConfig(v, args)

if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

tview.Styles = conf.Theme.Theme
preConfigedViddy := NewViddy(conf)
return preConfigedViddy
}

func (v *Viddy) ShowLogView(b bool) {
v.showLogView = b
v.arrange()
Expand Down

0 comments on commit cb2cb60

Please sign in to comment.