Skip to content

Commit

Permalink
use anonymous struct for env context
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Sep 16, 2021
1 parent ab0c78a commit 4d5e822
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4d5e822

Please sign in to comment.