Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update post installation text #408

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions cmd/krew/cmd/info.go
Expand Up @@ -73,24 +73,23 @@ func printPluginInfo(out io.Writer, plugin index.Plugin) {
fmt.Fprintf(out, "DESCRIPTION: \n%s\n", plugin.Spec.Description)
}
if plugin.Spec.Caveats != "" {
fmt.Fprintln(out, prepCaveats(plugin.Spec.Caveats))
fmt.Fprintf(out, "CAVEATS:\n%s\n", indent(plugin.Spec.Caveats))
}
}

// prepCaveats converts caveats string to an indented format ready for printing.
// indent converts strings to an indented format ready for printing.
// Example:
//
// CAVEATS:
// \
// | This plugin is great, use it with great care.
// | Also, plugin will require the following programs to run:
// | * jq
// | * base64
// /
func prepCaveats(s string) string {
out := "CAVEATS:\n\\\n"
func indent(s string) string {
out := "\\\n"
s = strings.TrimRightFunc(s, unicode.IsSpace)
out += regexp.MustCompile("(?m)^").ReplaceAllString(s, " | ")
out += regexp.MustCompile("(?m)^").ReplaceAllString(s, " | ")
out += "\n/"
return out
}
Expand Down
9 changes: 7 additions & 2 deletions cmd/krew/cmd/install.go
Expand Up @@ -132,10 +132,15 @@ Remarks:
failed = append(failed, plugin.Name)
continue
}
fmt.Fprintf(os.Stderr, "Installed plugin: %s\n", plugin.Name)
output := fmt.Sprintf("Use this plugin:\n\tkubectl %s\n", plugin.Name)
if plugin.Spec.Homepage != "" {
output += fmt.Sprintf("Documentation:\n\t%s\n", plugin.Spec.Homepage)
}
if plugin.Spec.Caveats != "" {
fmt.Fprintln(os.Stderr, prepCaveats(plugin.Spec.Caveats))
output += fmt.Sprintf("Caveats:\n%s\n", indent(plugin.Spec.Caveats))
}
fmt.Fprintf(os.Stderr, "Installed plugin: %s\n", plugin.Name)
fmt.Fprintln(os.Stderr, indent(output))
internal.PrintSecurityNotice()
}
if len(failed) > 0 {
Expand Down