mirror of https://github.com/containers/podman.git
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>
This commit is contained in:
parent
78c66fb005
commit
ea1fcd7bc7
|
@ -23,6 +23,7 @@ type searchOptionsWrapper struct {
|
||||||
Compatible bool // Docker compat
|
Compatible bool // Docker compat
|
||||||
TLSVerifyCLI bool // Used to convert to an optional bool later
|
TLSVerifyCLI bool // Used to convert to an optional bool later
|
||||||
Format string // For go templating
|
Format string // For go templating
|
||||||
|
NoTrunc bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// listEntryTag is a utility structure used for json serialization.
|
// 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")
|
flags.IntVar(&searchOptions.Limit, limitFlagName, 0, "Limit the number of results")
|
||||||
_ = cmd.RegisterFlagCompletionFunc(limitFlagName, completion.AutocompleteNone)
|
_ = 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)")
|
flags.BoolVar(&searchOptions.Compatible, "compatible", false, "List stars, official and automated columns (Docker compatibility)")
|
||||||
|
|
||||||
authfileFlagName := "authfile"
|
authfileFlagName := "authfile"
|
||||||
|
@ -139,11 +140,10 @@ func imageSearch(cmd *cobra.Command, args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
noTrunc, _ := cmd.Flags().GetBool("no-trunc")
|
|
||||||
isJSON := report.IsJSON(searchOptions.Format)
|
isJSON := report.IsJSON(searchOptions.Format)
|
||||||
for i, element := range searchReport {
|
for i, element := range searchReport {
|
||||||
d := strings.ReplaceAll(element.Description, "\n", " ")
|
d := strings.ReplaceAll(element.Description, "\n", " ")
|
||||||
if len(d) > 44 && !(noTrunc || isJSON) {
|
if len(d) > 44 && !(searchOptions.NoTrunc || isJSON) {
|
||||||
d = strings.TrimSpace(d[:44]) + "..."
|
d = strings.TrimSpace(d[:44]) + "..."
|
||||||
}
|
}
|
||||||
searchReport[i].Description = d
|
searchReport[i].Description = d
|
||||||
|
|
|
@ -90,7 +90,7 @@ The result contains the Image name and its tag, one line for every tag associate
|
||||||
|
|
||||||
#### **--no-trunc**
|
#### **--no-trunc**
|
||||||
|
|
||||||
Do not truncate the output (default *true*).
|
Do not truncate the output (default *false*).
|
||||||
|
|
||||||
#### **--tls-verify**
|
#### **--tls-verify**
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue