MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / main

Function main

cmd/testsummarize/main-testsummarize.go:36–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36func main() {
37 var showHelp bool
38 var mode string
39 flag.BoolVar(&showHelp, "help", false, "Show usage information")
40 flag.StringVar(&mode, "mode", "quick", "Summarization mode")
41 flag.StringVar(&mode, "m", "quick", "Summarization mode (shorthand)")
42 flag.Parse()
43
44 if showHelp {
45 printUsage()
46 os.Exit(0)
47 }
48
49 apiKey := os.Getenv("GOOGLE_APIKEY")
50 if apiKey == "" {
51 fmt.Println("Error: GOOGLE_APIKEY environment variable not set")
52 printUsage()
53 os.Exit(1)
54 }
55
56 args := flag.Args()
57 if len(args) == 0 {
58 fmt.Println("Error: filename required")
59 printUsage()
60 os.Exit(1)
61 }
62
63 filename := args[0]
64
65 // Check if file exists
66 if _, err := os.Stat(filename); os.IsNotExist(err) {
67 fmt.Printf("Error: file '%s' does not exist\n", filename)
68 os.Exit(1)
69 }
70
71 ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
72 defer cancel()
73
74 fmt.Printf("Summarizing file: %s\n", filename)
75 fmt.Printf("Model: %s\n", google.SummarizeModel)
76 fmt.Printf("Mode: %s\n", mode)
77
78 startTime := time.Now()
79 summary, usage, err := google.SummarizeFile(ctx, filename, google.SummarizeOpts{
80 APIKey: apiKey,
81 Mode: mode,
82 })
83 latency := time.Since(startTime)
84
85 fmt.Printf("Latency: %d ms\n", latency.Milliseconds())
86 fmt.Println("===")
87 if err != nil {
88 fmt.Printf("Error: %v\n", err)
89 os.Exit(1)
90 }
91
92 fmt.Println("\nSummary:")
93 fmt.Println("---")

Callers

nothing calls this directly

Calls 4

SummarizeFileFunction · 0.92
ParseMethod · 0.80
StatMethod · 0.80
printUsageFunction · 0.70

Tested by

no test coverage detected