From 2f3228e0eb51e8392c1b1c53940155ca1639d8d8 Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Thu, 2 Jan 2025 15:16:30 -0800 Subject: [PATCH] remember device name --- cmd/lk/cloud.go | 10 ++++++++-- pkg/config/config.go | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/lk/cloud.go b/cmd/lk/cloud.go index 55f5bad..9ed8065 100644 --- a/cmd/lk/cloud.go +++ b/cmd/lk/cloud.go @@ -269,8 +269,8 @@ func tryAuthIfNeeded(ctx context.Context, cmd *cli.Command) error { return err } - // name - var deviceName string + // get devicename + deviceName := cliConfig.DeviceName if err := huh.NewInput(). Title("What is the name of this device?"). Value(&deviceName). @@ -278,6 +278,12 @@ func tryAuthIfNeeded(ctx context.Context, cmd *cli.Command) error { Run(); err != nil { return err } + + // remember device name for next time + cliConfig.DeviceName = deviceName + if err := cliConfig.PersistIfNeeded(); err != nil { + return err + } fmt.Println("Device:", deviceName) // request token diff --git a/pkg/config/config.go b/pkg/config/config.go index 34b78d8..cb4f1de 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -27,6 +27,7 @@ import ( type CLIConfig struct { DefaultProject string `yaml:"default_project"` Projects []ProjectConfig `yaml:"projects"` + DeviceName string `yaml:"device_name"` // absent from YAML hasPersisted bool }