1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 07:57:07 +00:00
kyverno/cmd/cli/kubectl-kyverno/command/docs.go
Charles-Edouard Brétéché 3b44af8dbd
refactor: move utils cobra to command package (#8291)
* 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>
2023-09-06 14:44:50 +00:00

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")
}