Skip to content

Commit 5802c6b

Browse files
committed
populate templateNames from the interactive picker too
1 parent 5b51ea3 commit 5802c6b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

cli/templatedelete.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ func templateDelete() *cobra.Command {
3333

3434
if len(args) > 0 {
3535
templateNames = args
36+
37+
for _, templateName := range templateNames {
38+
template, err := client.TemplateByName(ctx, organization.ID, templateName)
39+
if err != nil {
40+
return xerrors.Errorf("get template by name: %w", err)
41+
}
42+
43+
templates = append(templates, template)
44+
}
45+
3646
} else {
3747
allTemplates, err := client.TemplatesByOrganization(ctx, organization.ID)
3848
if err != nil {
@@ -58,19 +68,11 @@ func templateDelete() *cobra.Command {
5868
for _, template := range allTemplates {
5969
if template.Name == selection {
6070
templates = append(templates, template)
71+
templateNames = append(templateNames, template.Name)
6172
}
6273
}
6374
}
6475

65-
for _, templateName := range templateNames {
66-
template, err := client.TemplateByName(ctx, organization.ID, templateName)
67-
if err != nil {
68-
return xerrors.Errorf("get template by name: %w", err)
69-
}
70-
71-
templates = append(templates, template)
72-
}
73-
7476
// Confirm deletion of the template.
7577
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
7678
Text: fmt.Sprintf("Delete these templates: %s?", cliui.Styles.Code.Render(strings.Join(templateNames, ", "))),

0 commit comments

Comments
 (0)