2019-11-15 03:50:49 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/cheat/cheat/internal/config"
|
2020-06-26 00:21:51 +02:00
|
|
|
"github.com/cheat/cheat/internal/display"
|
2019-11-15 03:50:49 +01:00
|
|
|
"github.com/cheat/cheat/internal/sheets"
|
|
|
|
)
|
|
|
|
|
|
|
|
// cmdTags lists all tags in use.
|
2023-12-13 15:10:20 +01:00
|
|
|
func cmdTags(_ map[string]interface{}, conf config.Config) {
|
2019-11-15 03:50:49 +01:00
|
|
|
|
|
|
|
// load the cheatsheets
|
|
|
|
cheatsheets, err := sheets.Load(conf.Cheatpaths)
|
|
|
|
if err != nil {
|
2022-08-05 02:38:49 +02:00
|
|
|
fmt.Fprintf(os.Stderr, "failed to list cheatsheets: %v\n", err)
|
2019-11-15 03:50:49 +01:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2020-06-26 00:21:51 +02:00
|
|
|
// assemble the output
|
|
|
|
out := ""
|
2019-11-15 03:50:49 +01:00
|
|
|
for _, tag := range sheets.Tags(cheatsheets) {
|
2020-06-26 00:21:51 +02:00
|
|
|
out += fmt.Sprintln(tag)
|
2019-11-15 03:50:49 +01:00
|
|
|
}
|
2020-06-26 00:21:51 +02:00
|
|
|
|
|
|
|
// display the output
|
2020-11-28 04:35:24 +01:00
|
|
|
display.Write(out, conf)
|
2019-11-15 03:50:49 +01:00
|
|
|
}
|