mirror of https://github.com/docker/docs.git
CLI: Add missing `pad` and `truncate` output formatting functions (#22384)
See https://github.com/docker/cli/blob/master/templates/templates.go --------- Co-authored-by: Usha Mandya <47779042+usha-mandya@users.noreply.github.com>
This commit is contained in:
parent
b2950312d8
commit
01505f4d80
|
@ -90,6 +90,26 @@ $ docker inspect --format "{{title .Name}}" container
|
||||||
$ docker inspect --format "{{upper .Name}}" container
|
$ docker inspect --format "{{upper .Name}}" container
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## pad
|
||||||
|
|
||||||
|
`pad` adds whitespace padding to a string. You can specify the number of spaces to add before and after the string.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker image list --format '{{pad .Repository 5 10}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
This example adds 5 spaces before the image repository name and 10 spaces after.
|
||||||
|
|
||||||
|
## truncate
|
||||||
|
|
||||||
|
`truncate` shortens a string to a specified length. If the string is shorter than the specified length, it remains unchanged.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker image list --format '{{truncate .Repository 15}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
This example displays the image repository name, truncating it to the first 15 characters if it's longer.
|
||||||
|
|
||||||
## println
|
## println
|
||||||
|
|
||||||
`println` prints each value on a new line.
|
`println` prints each value on a new line.
|
||||||
|
|
Loading…
Reference in New Issue