mirror of
https://github.com/cheat/cheat.git
synced 2025-09-04 19:18:29 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
ad7ad64a75 | |||
c4dcfd5da0 | |||
278a5d9154 | |||
9fa0c466fd |
@ -55,6 +55,7 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sort the cheatsheets alphabetically, and search for matches
|
// sort the cheatsheets alphabetically, and search for matches
|
||||||
|
out := ""
|
||||||
for _, sheet := range sheets.Sort(consolidated) {
|
for _, sheet := range sheets.Sort(consolidated) {
|
||||||
|
|
||||||
// assume that we want to perform a case-insensitive search for <phrase>
|
// assume that we want to perform a case-insensitive search for <phrase>
|
||||||
@ -88,14 +89,14 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// output the cheatsheet title
|
// output the cheatsheet title
|
||||||
out := fmt.Sprintf("%s:\n", sheet.Title)
|
out += fmt.Sprintf("%s:\n", sheet.Title)
|
||||||
|
|
||||||
// indent each line of content with two spaces
|
// indent each line of content with two spaces
|
||||||
for _, line := range strings.Split(sheet.Text, "\n") {
|
for _, line := range strings.Split(sheet.Text, "\n") {
|
||||||
out += fmt.Sprintf(" %s\n", line)
|
out += fmt.Sprintf(" %s\n", line)
|
||||||
}
|
}
|
||||||
|
|
||||||
// display the output
|
|
||||||
display.Display(out, conf)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// display the output
|
||||||
|
display.Display(out, conf)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/cheat/cheat/internal/installer"
|
"github.com/cheat/cheat/internal/installer"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "4.0.0"
|
const version = "4.0.2"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ func Paths(
|
|||||||
paths = append(paths, path.Join(xdgpath, "/cheat/conf.yml"))
|
paths = append(paths, path.Join(xdgpath, "/cheat/conf.yml"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// if `XDG_CONFIG_HOME` is not set, search the user's home directory
|
|
||||||
paths = append(paths, []string{
|
paths = append(paths, []string{
|
||||||
path.Join(home, ".config/cheat/conf.yml"),
|
path.Join(home, ".config/cheat/conf.yml"),
|
||||||
path.Join(home, ".cheat/conf.yml"),
|
path.Join(home, ".cheat/conf.yml"),
|
||||||
|
"/etc/cheat/conf.yml",
|
||||||
}...)
|
}...)
|
||||||
|
|
||||||
return paths, nil
|
return paths, nil
|
||||||
|
@ -39,6 +39,7 @@ func TestValidatePathsNix(t *testing.T) {
|
|||||||
"/home/bar/cheat/conf.yml",
|
"/home/bar/cheat/conf.yml",
|
||||||
"/home/foo/.config/cheat/conf.yml",
|
"/home/foo/.config/cheat/conf.yml",
|
||||||
"/home/foo/.cheat/conf.yml",
|
"/home/foo/.cheat/conf.yml",
|
||||||
|
"/etc/cheat/conf.yml",
|
||||||
}
|
}
|
||||||
|
|
||||||
// assert that output matches expectations
|
// assert that output matches expectations
|
||||||
@ -81,6 +82,7 @@ func TestValidatePathsNixNoXDG(t *testing.T) {
|
|||||||
want := []string{
|
want := []string{
|
||||||
"/home/foo/.config/cheat/conf.yml",
|
"/home/foo/.config/cheat/conf.yml",
|
||||||
"/home/foo/.cheat/conf.yml",
|
"/home/foo/.cheat/conf.yml",
|
||||||
|
"/etc/cheat/conf.yml",
|
||||||
}
|
}
|
||||||
|
|
||||||
// assert that output matches expectations
|
// assert that output matches expectations
|
||||||
|
Reference in New Issue
Block a user