MCPcopy Create free account
hub / github.com/alibaba/open-code-review / runSessionList

Function runSessionList

cmd/opencodereview/session_cmd.go:33–73  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

31}
32
33func runSessionList(args []string) error {
34 a := newOcrFlagSet("ocr session list")
35 var repoDir string
36 var asJSON bool
37 var limit int
38 a.StringVar(&repoDir, "repo", "", "root directory of the git repository (default: current dir)")
39 a.BoolVar(&asJSON, "json", false, "emit JSON instead of a table")
40 a.IntVar(&limit, "limit", 20, "cap the number of listed sessions (0 = unlimited)")
41 if err := a.Parse(args); err != nil {
42 return err
43 }
44 if a.showHelp {
45 printSessionListUsage()
46 return nil
47 }
48
49 resolvedRepo, err := resolveWorkingDirForSession(repoDir)
50 if err != nil {
51 return err
52 }
53 summaries, err := session.ListSessions(resolvedRepo)
54 if err != nil {
55 return fmt.Errorf("list sessions: %w", err)
56 }
57 if limit > 0 && len(summaries) > limit {
58 summaries = summaries[:limit]
59 }
60
61 if asJSON {
62 enc := json.NewEncoder(os.Stdout)
63 enc.SetIndent("", " ")
64 return enc.Encode(summaries)
65 }
66
67 if len(summaries) == 0 {
68 fmt.Printf("No sessions found for %s\n", resolvedRepo)
69 return nil
70 }
71 printSessionTable(os.Stdout, summaries)
72 return nil
73}
74
75func runSessionShow(args []string) error {
76 a := newOcrFlagSet("ocr session show")

Callers 4

runSessionFunction · 0.85
TestRunSessionList_JSONFunction · 0.85

Calls 9

ListSessionsFunction · 0.92
newOcrFlagSetFunction · 0.85
printSessionListUsageFunction · 0.85
printSessionTableFunction · 0.85
StringVarMethod · 0.80
BoolVarMethod · 0.80
IntVarMethod · 0.80
ParseMethod · 0.80