mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 07:57:07 +00:00
* refactor: introduce cli variables package Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * lint Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * refactor: move utils cobra to command package Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
45 lines
981 B
Go
45 lines
981 B
Go
package command
|
|
|
|
import "strings"
|
|
|
|
func FormatDescription(short bool, url string, experimental bool, lines ...string) string {
|
|
if len(lines) == 0 {
|
|
return ""
|
|
}
|
|
description := lines[0]
|
|
if short {
|
|
return description
|
|
}
|
|
description += "\n"
|
|
for _, line := range lines[1:] {
|
|
description += " "
|
|
description += line
|
|
description += "\n"
|
|
}
|
|
if experimental {
|
|
description += "\n"
|
|
description += " "
|
|
description += "NOTE: This is an experimental command, use `KYVERNO_EXPERIMENTAL=true` to enable it."
|
|
description += "\n"
|
|
}
|
|
if url != "" {
|
|
description += "\n"
|
|
description += " "
|
|
description += "For more information visit " + url
|
|
description += "\n"
|
|
}
|
|
return strings.TrimSpace(description)
|
|
}
|
|
|
|
func FormatExamples(in ...[]string) string {
|
|
var examples string
|
|
for _, example := range in {
|
|
for _, line := range example {
|
|
examples += " "
|
|
examples += line
|
|
examples += "\n"
|
|
}
|
|
examples += "\n"
|
|
}
|
|
return strings.TrimRight(examples, " \n")
|
|
}
|