mirror of https://github.com/cheat/cheat.git
feat(search): improve search output formatting
Improve the search output formatting.
This commit is contained in:
parent
233a9de1aa
commit
606092e288
|
@ -88,15 +88,18 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
||||||
sheet.Colorize(conf)
|
sheet.Colorize(conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// output the cheatsheet title
|
// display the cheatsheet title and path
|
||||||
out += fmt.Sprintf("%s:\n", sheet.Title)
|
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
|
// indent each line of content
|
||||||
for _, line := range strings.Split(sheet.Text, "\n") {
|
out += display.Indent(sheet.Text) + "\n"
|
||||||
out += fmt.Sprintf(" %s\n", line)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// display the output
|
// 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)
|
display.Display(out, conf)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue