2019-10-20 16:02:28 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-06-26 00:21:51 +02:00
|
|
|
"bytes"
|
2019-10-20 16:02:28 +02:00
|
|
|
"fmt"
|
|
|
|
"text/tabwriter"
|
|
|
|
|
|
|
|
"github.com/cheat/cheat/internal/config"
|
2020-06-26 00:21:51 +02:00
|
|
|
"github.com/cheat/cheat/internal/display"
|
2019-10-20 16:02:28 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// cmdDirectories lists the configured cheatpaths.
|
2023-12-13 15:10:20 +01:00
|
|
|
func cmdDirectories(_ map[string]interface{}, conf config.Config) {
|
2019-10-20 16:02:28 +02:00
|
|
|
|
|
|
|
// initialize a tabwriter to produce cleanly columnized output
|
2020-06-26 00:21:51 +02:00
|
|
|
var out bytes.Buffer
|
|
|
|
w := tabwriter.NewWriter(&out, 0, 0, 1, ' ', 0)
|
2019-10-20 16:02:28 +02:00
|
|
|
|
|
|
|
// generate sorted, columnized output
|
|
|
|
for _, path := range conf.Cheatpaths {
|
2022-08-05 02:38:49 +02:00
|
|
|
fmt.Fprintf(w, "%s:\t%s\n", path.Name, path.Path)
|
2019-10-20 16:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// write columnized output to stdout
|
|
|
|
w.Flush()
|
2020-11-28 04:35:24 +01:00
|
|
|
display.Write(out.String(), conf)
|
2019-10-20 16:02:28 +02:00
|
|
|
}
|