MCPcopy Index your code
hub / github.com/cheat/cheat / writeToPager

Function writeToPager

internal/display/write.go:26–41  ·  view source on GitHub ↗

writeToPager writes output through a pager command

(out string, conf config.Config)

Source from the content-addressed store, hash-verified

24
25// writeToPager writes output through a pager command
26func writeToPager(out string, conf config.Config) {
27 parts := strings.Fields(conf.Pager)
28 pager := parts[0]
29 args := parts[1:]
30
31 // configure the pager
32 cmd := exec.Command(pager, args...)
33 cmd.Stdin = strings.NewReader(out)
34 cmd.Stdout = os.Stdout
35
36 // run the pager and handle errors
37 if err := cmd.Run(); err != nil {
38 fmt.Fprintf(os.Stderr, "failed to write to pager: %v\n", err)
39 os.Exit(1)
40 }
41}

Callers 3

TestWriteToPagerFunction · 0.85
TestWriteToPagerErrorFunction · 0.85
WriteFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestWriteToPagerFunction · 0.68
TestWriteToPagerErrorFunction · 0.68