MCPcopy Create free account
hub / github.com/cli/cli / cmdLog

Function cmdLog

script/ghmock/log.go:37–71  ·  view source on GitHub ↗
(args []string, stdout io.Writer)

Source from the content-addressed store, hash-verified

35}
36
37func cmdLog(args []string, stdout io.Writer) error {
38 opts, err := parseLogArgs(args)
39 if err != nil {
40 return err
41 }
42 st, err := openState()
43 if err != nil {
44 return err
45 }
46 entries, err := st.readLog()
47 if err != nil {
48 return err
49 }
50 if !opts.all {
51 entries, err = st.latestRequests(entries)
52 if err != nil {
53 return err
54 }
55 }
56 if len(entries) == 0 {
57 fmt.Fprintln(stdout, "No requests logged.")
58 return nil
59 }
60 if opts.asJSON {
61 enc := json.NewEncoder(stdout)
62 for _, e := range entries {
63 if err := enc.Encode(e); err != nil {
64 return err
65 }
66 }
67 return nil
68 }
69 printLog(stdout, entries, opts.full)
70 return nil
71}
72
73func (s *state) latestRequests(entries []loggedRequest) ([]loggedRequest, error) {
74 runs, err := s.readRuns()

Callers 3

TestCmdLogFunction · 0.85
TestRunAllFunction · 0.85
runMainFunction · 0.85

Calls 5

parseLogArgsFunction · 0.85
openStateFunction · 0.85
printLogFunction · 0.85
readLogMethod · 0.80
latestRequestsMethod · 0.80

Tested by 2

TestCmdLogFunction · 0.68
TestRunAllFunction · 0.68