Browse Source

feat: save token to default keyring if passed via flag (#180)

ayntgl 3 năm trước cách đây
mục cha
commit
ee08cd9593
4 tập tin đã thay đổi với 112 bổ sung131 xóa
  1. 6 9
      go.mod
  2. 15 24
      go.sum
  3. 91 96
      main.go
  4. 0 2
      ui/app.go

+ 6 - 9
go.mod

@@ -4,31 +4,28 @@ go 1.18
 
 require (
 	github.com/BurntSushi/toml v1.1.0
+	github.com/alecthomas/kong v0.6.1
 	github.com/atotto/clipboard v0.1.4
 	github.com/diamondburned/arikawa/v3 v3.0.0
 	github.com/gdamore/tcell/v2 v2.5.1
 	github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
 	github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
-	github.com/urfave/cli/v2 v2.7.1
 	github.com/zalando/go-keyring v0.2.1
 )
 
 require (
 	github.com/alessio/shellescape v1.4.1 // indirect
-	github.com/antzucaro/matchr v0.0.0-20210222213004-b04723ef80f0 // indirect
-	github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
-	github.com/danieljoos/wincred v1.1.2 // indirect
+	github.com/danieljoos/wincred v1.1.0 // indirect
 	github.com/gdamore/encoding v1.0.0 // indirect
-	github.com/godbus/dbus/v5 v5.1.0 // indirect
+	github.com/godbus/dbus/v5 v5.0.6 // indirect
 	github.com/gorilla/schema v1.2.0 // indirect
-	github.com/gorilla/websocket v1.5.0 // indirect
+	github.com/gorilla/websocket v1.4.2 // indirect
 	github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
 	github.com/mattn/go-runewidth v0.0.13 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
 	github.com/rivo/uniseg v0.2.0 // indirect
-	github.com/russross/blackfriday/v2 v2.1.0 // indirect
-	golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
-	golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
+	golang.org/x/sys v0.0.0-20220318055525-2edf467146b5 // indirect
+	golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
 	golang.org/x/text v0.3.7 // indirect
 	golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
 )

+ 15 - 24
go.sum

@@ -1,18 +1,18 @@
 github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
 github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
+github.com/alecthomas/kong v0.6.1 h1:1kNhcFepkR+HmasQpbiKDLylIL8yh5B5y1zPp5bJimA=
+github.com/alecthomas/kong v0.6.1/go.mod h1:JfHWDzLmbh/puW6I3V7uWenoh56YNVONW+w8eKeUr9I=
+github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48=
+github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
 github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
 github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
-github.com/antzucaro/matchr v0.0.0-20210222213004-b04723ef80f0 h1:R/qAiUxFT3mNgQaNqJe0IVznjKRNm23ohAIh9lgtlzc=
-github.com/antzucaro/matchr v0.0.0-20210222213004-b04723ef80f0/go.mod h1:v3ZDlfVAL1OrkKHbGSFFK60k0/7hruHPDq2XMs9Gu6U=
 github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
 github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
-github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
-github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/danieljoos/wincred v1.1.0 h1:3RNcEpBg4IhIChZdFRSdlQt1QjCp1sMAPIrOnm7Yf8g=
 github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg=
-github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
-github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/diamondburned/arikawa/v3 v3.0.0 h1:VbdX1DtrBLE752IJftZHInVy6v8I3T8vhN9rKGvO6AY=
 github.com/diamondburned/arikawa/v3 v3.0.0/go.mod h1:5jBSNnp82Z/EhsKa6Wk9FsOqSxfVkNZDTDBPOj47LpY=
 github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
@@ -20,14 +20,12 @@ github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo
 github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1/go.mod h1:Az6Jt+M5idSED2YPGtwnfJV0kXohgdCBPmHGSYc1r04=
 github.com/gdamore/tcell/v2 v2.5.1 h1:zc3LPdpK184lBW7syF2a5C6MV827KmErk9jGVnmsl/I=
 github.com/gdamore/tcell/v2 v2.5.1/go.mod h1:wSkrPaXoiIWZqW/g7Px4xc79di6FTcpB8tvaKJ6uGBo=
+github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro=
 github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
-github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
-github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
 github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc=
 github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU=
+github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
-github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
 github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
 github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
@@ -40,17 +38,13 @@ github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8 h1:xe+mmCnDN82KhC010l3N
 github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8/go.mod h1:WIfMkQNY+oq/mWwtsjOYHIZBuwthioY2srOmljJkTnk=
 github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
 github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
-github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
 github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/urfave/cli/v2 v2.7.1 h1:DsAOFeI9T0vmUW4LiGR5mhuCIn5kqGIE4WMU2ytmH00=
-github.com/urfave/cli/v2 v2.7.1/go.mod h1:TYFbtzt/azQoJOrGH5mDfZtS0jIkl/OeFwlRWPR9KRM=
+github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
+github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
 github.com/zalando/go-keyring v0.2.1 h1:MBRN/Z8H4U5wEKXiD67YbDAr5cj/DOStmSga70/2qKc=
 github.com/zalando/go-keyring v0.2.1/go.mod h1:g63M2PPn0w5vjmEbwAX3ib5I+41zdm4esSETOn9Y6Dw=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -58,16 +52,13 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20211001092434-39dca1131b70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220318055525-2edf467146b5 h1:saXMvIOKvRFwbOMicHXr0B1uwoxq9dGmLe5ExMES6c4=
 golang.org/x/sys v0.0.0-20220318055525-2edf467146b5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
-golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
 golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8=
-golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -79,5 +70,5 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

+ 91 - 96
main.go

@@ -2,13 +2,12 @@ package main
 
 import (
 	"log"
-	"os"
 
+	"github.com/alecthomas/kong"
 	"github.com/ayntgl/discordo/config"
 	"github.com/ayntgl/discordo/ui"
 	"github.com/gdamore/tcell/v2"
 	"github.com/rivo/tview"
-	"github.com/urfave/cli/v2"
 	"github.com/zalando/go-keyring"
 )
 
@@ -17,63 +16,85 @@ const (
 	usage = "A lightweight, secure, and feature-rich Discord terminal client"
 )
 
+var cli struct {
+	Token  string `help:"The authentication token."`
+	Config string `help:"The path of the configuration file." type:"path"`
+}
+
 func main() {
-	t, _ := keyring.Get(name, "token")
-
-	cliApp := &cli.App{
-		Name:                 name,
-		Usage:                usage,
-		EnableBashCompletion: true,
-		Flags: []cli.Flag{
-			&cli.StringFlag{
-				Name:        "token",
-				Usage:       "The client authentication token.",
-				Value:       t,
-				DefaultText: "From keyring",
-				Aliases:     []string{"t"},
-			},
-			&cli.StringFlag{
-				Name:    "config",
-				Usage:   "The path of the configuration file.",
-				Value:   config.DefaultPath(),
-				Aliases: []string{"c"},
-			},
-		},
+	kong.Parse(&cli, kong.Name(name), kong.Description(usage), kong.UsageOnError())
+
+	// If the authentication token is provided via a flag, store it in the default keyring.
+	if cli.Token != "" {
+		go keyring.Set(name, "token", cli.Token)
+	}
+
+	// Defaults
+	if cli.Config == "" {
+		cli.Config = config.DefaultPath()
+	}
+
+	if cli.Token == "" {
+		cli.Token, _ = keyring.Get(name, "token")
+	}
+
+	c := config.New()
+	err := c.Load(cli.Config)
+	if err != nil {
+		log.Fatal(err)
 	}
 
-	cliApp.Action = func(ctx *cli.Context) error {
-		c := config.New()
-		err := c.Load(ctx.String("config"))
+	app := ui.NewApp(cli.Token, c)
+	if cli.Token != "" {
+		err := app.Connect()
 		if err != nil {
-			return err
+			log.Fatal(err)
 		}
 
-		token := ctx.String("token")
-		app := ui.NewApp(token, c)
-		if token != "" {
-			err := app.Connect()
-			if err != nil {
-				return err
+		app.DrawMainFlex()
+
+		app.SetRoot(app.MainFlex, true)
+		app.SetFocus(app.GuildsTree)
+	} else {
+		loginForm := ui.NewLoginForm(false)
+		loginForm.AddButton("Login", func() {
+			email := loginForm.GetFormItem(0).(*tview.InputField).GetText()
+			password := loginForm.GetFormItem(1).(*tview.InputField).GetText()
+			if email == "" || password == "" {
+				return
 			}
 
-			app.DrawMainFlex()
-			app.SetFocus(app.GuildsTree)
-		} else {
-			loginForm := ui.NewLoginForm(false)
-			loginForm.AddButton("Login", func() {
-				email := loginForm.GetFormItem(0).(*tview.InputField).GetText()
-				password := loginForm.GetFormItem(1).(*tview.InputField).GetText()
-				if email == "" || password == "" {
-					return
-				}
+			// Login using the email and password only
+			lr, err := app.State.Login(email, password)
+			if err != nil {
+				log.Fatal(err)
+			}
 
-				// Login using the email and password only
-				lr, err := app.State.Login(email, password)
+			if lr.Token != "" && !lr.MFA {
+				app.State.Token = lr.Token
+				err = app.Connect()
 				if err != nil {
 					log.Fatal(err)
 				}
 
-				if lr.Token != "" && !lr.MFA {
+				app.DrawMainFlex()
+				app.SetRoot(app.MainFlex, true)
+				app.SetFocus(app.GuildsTree)
+				go keyring.Set(name, "token", lr.Token)
+			} else {
+				// The account has MFA enabled, reattempt login with MFA code and ticket.
+				mfaLoginForm := ui.NewLoginForm(true)
+				mfaLoginForm.AddButton("Login", func() {
+					code := mfaLoginForm.GetFormItem(0).(*tview.InputField).GetText()
+					if code == "" {
+						return
+					}
+
+					lr, err = app.State.TOTP(code, lr.Ticket)
+					if err != nil {
+						log.Fatal(err)
+					}
+
 					app.State.Token = lr.Token
 					err = app.Connect()
 					if err != nil {
@@ -81,63 +102,37 @@ func main() {
 					}
 
 					app.DrawMainFlex()
+					app.SetRoot(app.MainFlex, true)
 					app.SetFocus(app.GuildsTree)
 
 					go keyring.Set(name, "token", lr.Token)
-				} else {
-					// The account has MFA enabled, reattempt login with MFA code and ticket.
-					mfaLoginForm := ui.NewLoginForm(true)
-					mfaLoginForm.AddButton("Login", func() {
-						code := mfaLoginForm.GetFormItem(0).(*tview.InputField).GetText()
-						if code == "" {
-							return
-						}
-
-						lr, err = app.State.TOTP(code, lr.Ticket)
-						if err != nil {
-							log.Fatal(err)
-						}
-
-						app.State.Token = lr.Token
-						err = app.Connect()
-						if err != nil {
-							log.Fatal(err)
-						}
-
-						app.DrawMainFlex()
-						app.SetFocus(app.GuildsTree)
-
-						go keyring.Set(name, "token", lr.Token)
-					})
-
-					app.SetRoot(mfaLoginForm, true)
-				}
-			})
+				})
 
-			app.SetRoot(loginForm, true)
-		}
+				app.SetRoot(mfaLoginForm, true)
+			}
+		})
 
-		tview.Borders.TopLeftFocus = tview.Borders.TopLeft
-		tview.Borders.TopRightFocus = tview.Borders.TopRight
-		tview.Borders.BottomLeftFocus = tview.Borders.BottomLeft
-		tview.Borders.BottomRightFocus = tview.Borders.BottomRight
-		tview.Borders.HorizontalFocus = tview.Borders.Horizontal
-		tview.Borders.VerticalFocus = tview.Borders.Vertical
-		tview.Borders.TopLeft = 0
-		tview.Borders.TopRight = 0
-		tview.Borders.BottomLeft = 0
-		tview.Borders.BottomRight = 0
-		tview.Borders.Horizontal = 0
-		tview.Borders.Vertical = 0
-
-		tview.Styles.PrimitiveBackgroundColor = tcell.GetColor(app.Config.Theme.Background)
-		tview.Styles.BorderColor = tcell.GetColor(app.Config.Theme.Border)
-		tview.Styles.TitleColor = tcell.GetColor(app.Config.Theme.Title)
-
-		return app.Run()
+		app.SetRoot(loginForm, true)
 	}
 
-	err := cliApp.Run(os.Args)
+	tview.Borders.TopLeftFocus = tview.Borders.TopLeft
+	tview.Borders.TopRightFocus = tview.Borders.TopRight
+	tview.Borders.BottomLeftFocus = tview.Borders.BottomLeft
+	tview.Borders.BottomRightFocus = tview.Borders.BottomRight
+	tview.Borders.HorizontalFocus = tview.Borders.Horizontal
+	tview.Borders.VerticalFocus = tview.Borders.Vertical
+	tview.Borders.TopLeft = 0
+	tview.Borders.TopRight = 0
+	tview.Borders.BottomLeft = 0
+	tview.Borders.BottomRight = 0
+	tview.Borders.Horizontal = 0
+	tview.Borders.Vertical = 0
+
+	tview.Styles.PrimitiveBackgroundColor = tcell.GetColor(app.Config.Theme.Background)
+	tview.Styles.BorderColor = tcell.GetColor(app.Config.Theme.Border)
+	tview.Styles.TitleColor = tcell.GetColor(app.Config.Theme.Title)
+
+	err = app.Run()
 	if err != nil {
 		log.Fatal(err)
 	}

+ 0 - 2
ui/app.go

@@ -109,8 +109,6 @@ func (app *App) DrawMainFlex() {
 	app.MainFlex.
 		AddItem(leftFlex, 0, 1, false).
 		AddItem(rightFlex, 0, 4, false)
-
-	app.SetRoot(app.MainFlex, true)
 }
 
 func (app *App) onStateReady(r *gateway.ReadyEvent) {