add basic run command

This commit is contained in:
Moby von Briesen
2023-05-02 20:07:48 -04:00
parent 50db4d6d0e
commit 99bd1929b5
3 changed files with 154 additions and 29 deletions

View File

@@ -61,13 +61,11 @@ func getConfig() config {
}
func getPullPal(ctx context.Context, cfg config) (*pullpal.PullPal, error) {
/*
log, err := zap.NewProduction()
if err != nil {
panic(err)
}
*/
log := zap.L()
log, err := zap.NewProduction()
if err != nil {
panic(err)
}
//log := zap.L()
author := vc.Author{
Email: cfg.selfEmail,
@@ -82,7 +80,11 @@ func getPullPal(ctx context.Context, cfg config) (*pullpal.PullPal, error) {
Handle: cfg.repoHandle,
},
}
p, err := pullpal.NewPullPal(ctx, log.Named("pullpal"), author, repo, cfg.openAIToken)
listIssueOptions := vc.ListIssueOptions{
Handles: cfg.usersToListenTo,
Labels: cfg.requiredIssueLabels,
}
p, err := pullpal.NewPullPal(ctx, log.Named("pullpal"), listIssueOptions, author, repo, cfg.openAIToken)
return p, err
}
@@ -121,10 +123,7 @@ It can be used to:
var issue vc.Issue
var changeRequest llm.CodeChangeRequest
if cfg.promptToClipboard {
issue, changeRequest, err = p.PickIssueToClipboard(vc.ListIssueOptions{
Handles: cfg.usersToListenTo,
Labels: cfg.requiredIssueLabels,
})
issue, changeRequest, err = p.PickIssueToClipboard()
if err != nil {
if !errors.Is(err, pullpal.IssueNotFound) {
fmt.Println("error selecting issue and/or generating prompt", err)
@@ -136,10 +135,7 @@ It can be used to:
fmt.Printf("Picked issue and copied prompt to clipboard. Issue #%s\n", issue.ID)
}
} else {
issue, changeRequest, err = p.PickIssueToFile(vc.ListIssueOptions{
Handles: cfg.usersToListenTo,
Labels: cfg.requiredIssueLabels,
}, cfg.promptPath)
issue, changeRequest, err = p.PickIssueToFile(cfg.promptPath)
if err != nil {
if !errors.Is(err, pullpal.IssueNotFound) {
fmt.Println("error selecting issue and/or generating prompt", err)

32
cmd/run.go Normal file
View File

@@ -0,0 +1,32 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var runCmd = &cobra.Command{
Use: "run",
Short: "Runs a fully automated pull pal service",
Run: func(cmd *cobra.Command, args []string) {
cfg := getConfig()
p, err := getPullPal(cmd.Context(), cfg)
if err != nil {
fmt.Println("error creating new pull pal", err)
return
}
fmt.Println("Successfully initialized pull pal")
err = p.Run()
if err != nil {
fmt.Println("error running", err)
return
}
},
}
func init() {
rootCmd.AddCommand(runCmd)
}