@@ -33,6 +33,16 @@ func templateDelete() *cobra.Command {
33
33
34
34
if len (args ) > 0 {
35
35
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
+
36
46
} else {
37
47
allTemplates , err := client .TemplatesByOrganization (ctx , organization .ID )
38
48
if err != nil {
@@ -58,19 +68,11 @@ func templateDelete() *cobra.Command {
58
68
for _ , template := range allTemplates {
59
69
if template .Name == selection {
60
70
templates = append (templates , template )
71
+ templateNames = append (templateNames , template .Name )
61
72
}
62
73
}
63
74
}
64
75
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
-
74
76
// Confirm deletion of the template.
75
77
_ , err = cliui .Prompt (cmd , cliui.PromptOptions {
76
78
Text : fmt .Sprintf ("Delete these templates: %s?" , cliui .Styles .Code .Render (strings .Join (templateNames , ", " ))),
0 commit comments