Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions cmd/lk/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ func setupTemplate(ctx context.Context, cmd *cli.Command) error {
if err != nil {
return err
}
details, err := bootstrap.FetchSandboxDetails(ctx, sandboxID, token, serverURL)
if err != nil {
return err
}
if len(details.ChildTemplates) == 0 {
return errors.New("no child templates found for sandbox")
if templateURL == "" {
details, err := bootstrap.FetchSandboxDetails(ctx, sandboxID, token, serverURL)
if err != nil {
return err
}
if len(details.ChildTemplates) == 0 {
return errors.New("no child templates found for sandbox")
}
templateOptions = details.ChildTemplates
}
templateOptions = details.ChildTemplates
} else {
var err error
templateOptions, err = bootstrap.FetchTemplates(ctx)
Expand All @@ -189,28 +191,6 @@ func setupTemplate(ctx context.Context, cmd *cli.Command) error {
}
}

appName = cmd.Args().First()
if appName == "" {
appName = sandboxID
preinstallPrompts = append(preinstallPrompts, huh.NewInput().
Title("Application Name").
Placeholder("my-app").
Value(&appName).
Validate(func(s string) error {
if len(s) < 3 {
return errors.New("name is too short")
}
if !appNameRegex.MatchString(s) {
return errors.New("try a simpler name")
}
if s, _ := os.Stat(s); s != nil {
return errors.New("that name is in use")
}
return nil
}).
WithTheme(theme))
}

// if no template name or URL is specified, prompt user to choose from available templates
if templateName == "" && templateURL == "" {
templateSelect := huh.NewSelect[string]().
Expand All @@ -237,6 +217,28 @@ func setupTemplate(ctx context.Context, cmd *cli.Command) error {
}
}

appName = cmd.Args().First()
if appName == "" {
appName = sandboxID
preinstallPrompts = append(preinstallPrompts, huh.NewInput().
Title("Application Name").
Placeholder("my-app").
Value(&appName).
Validate(func(s string) error {
if len(s) < 3 {
return errors.New("name is too short")
}
if !appNameRegex.MatchString(s) {
return errors.New("try a simpler name")
}
if s, _ := os.Stat(s); s != nil {
return errors.New("that name is in use")
}
return nil
}).
WithTheme(theme))
}

if len(preinstallPrompts) > 0 {
group := huh.NewGroup(preinstallPrompts...)
if err := huh.NewForm(group).
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
package livekitcli

const (
Version = "2.1.4"
Version = "2.1.5"
)