From 606092e2883a0c32f72847f31bc27283e94ae124 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Fri, 27 Nov 2020 17:06:02 -0500 Subject: [PATCH] feat(search): improve search output formatting Improve the search output formatting. --- cmd/cheat/cmd_search.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/cheat/cmd_search.go b/cmd/cheat/cmd_search.go index 5ac1aa8..a4406d5 100644 --- a/cmd/cheat/cmd_search.go +++ b/cmd/cheat/cmd_search.go @@ -88,15 +88,18 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) { sheet.Colorize(conf) } - // output the cheatsheet title - out += fmt.Sprintf("%s:\n", sheet.Title) + // display the cheatsheet title and path + out += fmt.Sprintf("\n%s %s\n", + display.Underline(sheet.Title), + display.Faint(fmt.Sprintf("(%s)", sheet.CheatPath)), + ) - // indent each line of content with two spaces - for _, line := range strings.Split(sheet.Text, "\n") { - out += fmt.Sprintf(" %s\n", line) - } + // indent each line of content + out += display.Indent(sheet.Text) + "\n" } // display the output + // NB: resist the temptation to call `display.Display` multiple times in + // the loop above. That will not play nicely with the paginator. display.Display(out, conf) }