mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 11:13:33 +01:00
Replace docopt-go with spf13/cobra, giving cheat a built-in `--completion` flag that dynamically generates shell completions for bash, zsh, fish, and powershell. This replaces the manually-maintained static completion scripts and resolves the root cause of multiple completion issues (#768, #705, #633, #632, #476). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
654 B
Go
30 lines
654 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"text/tabwriter"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cheat/cheat/internal/config"
|
|
"github.com/cheat/cheat/internal/display"
|
|
)
|
|
|
|
// cmdDirectories lists the configured cheatpaths.
|
|
func cmdDirectories(_ *cobra.Command, _ []string, conf config.Config) {
|
|
|
|
// initialize a tabwriter to produce cleanly columnized output
|
|
var out bytes.Buffer
|
|
w := tabwriter.NewWriter(&out, 0, 0, 1, ' ', 0)
|
|
|
|
// generate sorted, columnized output
|
|
for _, path := range conf.Cheatpaths {
|
|
fmt.Fprintf(w, "%s:\t%s\n", path.Name, path.Path)
|
|
}
|
|
|
|
// write columnized output to stdout
|
|
w.Flush()
|
|
display.Write(out.String(), conf)
|
|
}
|