Skip to content

Commit cd05360

Browse files
committed
cli-plugins/hooks: slight tweaks in templates
- use `%q` instead of manually quoting the string - use `%d` instead of manually converting the number to a string Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent aadfe62 commit cd05360

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

cli-plugins/hooks/hook_utils.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package hooks
22

33
import (
44
"fmt"
5-
"strconv"
65
)
76

87
const (
98
hookTemplateCommandName = `{{.Name}}`
10-
hookTemplateFlagValue = `{{flag . "%s"}}`
11-
hookTemplateArg = `{{arg . %s}}`
9+
hookTemplateFlagValue = `{{flag . %q}}`
10+
hookTemplateArg = `{{arg . %d}}`
1211
)
1312

1413
// TemplateReplaceSubcommandName returns a hook template string
@@ -54,5 +53,5 @@ func TemplateReplaceFlagValue(flag string) string {
5453
// will result in the message:
5554
// "Run this image with `docker run alpine`"
5655
func TemplateReplaceArg(i int) string {
57-
return fmt.Sprintf(hookTemplateArg, strconv.Itoa(i))
56+
return fmt.Sprintf(hookTemplateArg, i)
5857
}

0 commit comments

Comments
 (0)