diff options
author | Valentin Rothberg <vrothberg@redhat.com> | 2022-04-28 09:40:46 +0200 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2022-05-03 13:34:46 -0400 |
commit | 77f147468c4bf514dd5a2951a29128f226d1186c (patch) | |
tree | 2789fba7c8a89c43b0a6edc86ce63f1178248693 /cmd/podman/images | |
parent | b1089a23bc85759d1ac9319d1816c999980d8231 (diff) | |
download | podman-77f147468c4bf514dd5a2951a29128f226d1186c.tar.gz podman-77f147468c4bf514dd5a2951a29128f226d1186c.tar.bz2 podman-77f147468c4bf514dd5a2951a29128f226d1186c.zip |
podman search: truncate by default
Truncate by default to avoid long descriptions from rendering the output
unreadable.
[NO NEW TESTS NEEDED]
Fixes: #14044
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Diffstat (limited to 'cmd/podman/images')
-rw-r--r-- | cmd/podman/images/search.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go index aa11cf254..7f202cb6a 100644 --- a/cmd/podman/images/search.go +++ b/cmd/podman/images/search.go @@ -23,6 +23,7 @@ type searchOptionsWrapper struct { Compatible bool // Docker compat TLSVerifyCLI bool // Used to convert to an optional bool later Format string // For go templating + NoTrunc bool } // listEntryTag is a utility structure used for json serialization. @@ -92,7 +93,7 @@ func searchFlags(cmd *cobra.Command) { flags.IntVar(&searchOptions.Limit, limitFlagName, 0, "Limit the number of results") _ = cmd.RegisterFlagCompletionFunc(limitFlagName, completion.AutocompleteNone) - flags.Bool("no-trunc", true, "Do not truncate the output. Default: true") + flags.BoolVar(&searchOptions.NoTrunc, "no-trunc", false, "Do not truncate the output") flags.BoolVar(&searchOptions.Compatible, "compatible", false, "List stars, official and automated columns (Docker compatibility)") authfileFlagName := "authfile" @@ -139,11 +140,10 @@ func imageSearch(cmd *cobra.Command, args []string) error { return nil } - noTrunc, _ := cmd.Flags().GetBool("no-trunc") isJSON := report.IsJSON(searchOptions.Format) for i, element := range searchReport { d := strings.ReplaceAll(element.Description, "\n", " ") - if len(d) > 44 && !(noTrunc || isJSON) { + if len(d) > 44 && !(searchOptions.NoTrunc || isJSON) { d = strings.TrimSpace(d[:44]) + "..." } searchReport[i].Description = d |