Skip to content

Commit 746372c

Browse files
authored
CLI: Add missing pad and truncate output formatting functions
See https://github.com/docker/cli/blob/master/templates/templates.go
1 parent 49328ef commit 746372c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

content/manuals/engine/cli/formatting.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ $ docker inspect --format "{{title .Name}}" container
9090
$ docker inspect --format "{{upper .Name}}" container
9191
```
9292

93+
## pad
94+
95+
`pad` adds whitespace padding to a string. You can specify the number of spaces to add before and after the string.
96+
97+
```console
98+
$ docker image list --format '{{pad .Repository 5 10}}'
99+
```
100+
101+
This example will add 5 spaces before the image repository name and 10 spaces after.
102+
103+
## truncate
104+
105+
`truncate` shortens a string to a specified length. If the string is shorter than the specified length, it remains unchanged.
106+
107+
```console
108+
$ docker image list --format '{{truncate .Repository 15}}'
109+
```
110+
111+
This example will display the image repository name, truncating it to the first 15 characters if it's longer.
112+
93113
## println
94114

95115
`println` prints each value on a new line.

0 commit comments

Comments
 (0)