From 4d5e82262980b4dbd58e4d5ee60804b92ea32f5b Mon Sep 17 00:00:00 2001 From: Gadzhi Kharkharov Date: Thu, 16 Sep 2021 15:48:08 +0300 Subject: [PATCH] use anonymous struct for env context --- cmd/cmd.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index e25d013..1f49708 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -37,33 +37,30 @@ type Cmd struct { useGitDirSessions bool } -type EnvContext struct { - Session string `json:"session"` - Client string `json:"client"` - defaultSession string - useGitDirSessions bool -} - func (c *Cmd) Run() error { return nil } func (c *Cmd) Name() string { return c.fs.Name() } func (c *Cmd) Alias() []string { return c.alias } func (c *Cmd) Init(args []string) error { - env := EnvContext{ - Session: os.Getenv("KKS_SESSION"), - Client: os.Getenv("KKS_CLIENT"), + env := struct { + session string + client string + useGitDirSessions bool + defaultSession string + }{ + session: os.Getenv("KKS_SESSION"), + client: os.Getenv("KKS_CLIENT"), defaultSession: os.Getenv("KKS_DEFAULT_SESSION"), } _, env.useGitDirSessions = os.LookupEnv("KKS_USE_GITDIR_SESSIONS") + c.fs.Usage = c.usage + c.session = env.session + c.client = env.client c.useGitDirSessions = env.useGitDirSessions c.defaultSession = env.defaultSession - c.fs.Usage = c.usage - c.session = env.Session - c.client = env.Client - if err := c.fs.Parse(args); err != nil { return err }