-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (40 loc) · 827 Bytes
/
main.go
File metadata and controls
50 lines (40 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/andreimerlescu/goenv/env"
)
func main() {
isDebug = env.Bool(eAlwaysDebug, dAlwaysDebug)
configure()
if err := figs.Load(); err != nil {
fmt.Printf("Error loading config: %v\n", err)
return
}
if *figs.Bool(kShowVersion) {
fmt.Println(Version())
return
}
bytes, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Printf("Error reading from stdin: %v\n", err)
return
}
if isDebug {
fmt.Printf("Content read (all at once):\n%s\n", string(bytes))
}
prompt, err := NewPrompt(bytes)
if err != nil {
fmt.Printf("Error creating prompt: %v\n", err)
return
}
ctx := context.Background()
response, err := Call(ctx, prompt)
if err != nil {
fmt.Printf("Error calling prompt: %v\n", err)
return
}
fmt.Println(Clean(response))
}