Skip to content

Commit 3e63f1f

Browse files
authored
chore(agents): fallback to agent selector when generating config (#642)
* chore(agents): fallback to agent selector when generating config * fix(agents): `lk agent config` respects workingDir * chore: bump version
1 parent 95518e5 commit 3e63f1f

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

cmd/lk/agent.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,24 @@ func createAgentConfig(ctx context.Context, cmd *cli.Command) error {
464464
return err
465465
}
466466
if !overwrite {
467-
return fmt.Errorf("config file [%s] already exists", tomlFilename)
467+
return fmt.Errorf("config file [%s] already exists", util.Accented(tomlFilename))
468468
}
469469
}
470470

471471
agentID := cmd.String("id")
472472
if agentID == "" {
473-
if err := huh.NewInput().
474-
Title("Agent ID").
475-
Value(&agentID).
476-
WithTheme(util.Theme).
477-
Run(); err != nil {
473+
configExists, err := requireConfig(workingDir, tomlFilename)
474+
if err != nil && configExists {
478475
return err
479-
} else if agentID == "" {
480-
return fmt.Errorf("agent ID is required")
476+
}
477+
478+
if configExists && lkConfig.HasAgent() {
479+
agentID = lkConfig.Agent.ID
480+
} else {
481+
agentID, err = selectAgent(ctx, cmd, false)
482+
if err != nil {
483+
return err
484+
}
481485
}
482486
}
483487

@@ -514,7 +518,7 @@ func createAgentConfig(ctx context.Context, cmd *cli.Command) error {
514518
Regions: regions,
515519
}
516520

517-
if err := lkConfig.SaveTOMLFile("", tomlFilename); err != nil {
521+
if err := lkConfig.SaveTOMLFile(workingDir, tomlFilename); err != nil {
518522
return err
519523
}
520524
return nil

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
package livekitcli
1616

1717
const (
18-
Version = "2.4.15"
18+
Version = "2.5.0"
1919
)

0 commit comments

Comments
 (0)