From 4153d4f9880dd94c95b0348cd74b3733c8b301da Mon Sep 17 00:00:00 2001 From: kevin_mesiab Date: Tue, 16 Jan 2024 20:20:41 -0800 Subject: [PATCH] feat: Add emojis to console output * Update the GPT model to gpt-4-1106-preview --- README.md | 4 ++++ go.sum | 7 ------- main.go | 40 ++++++++++++++++++++++++---------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index cf00d06..3a1b3ce 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ To review a pull request, run the following command: ./cadre --url [url to github pull request] ``` +ex: + +![Screenshot](./assets/cadre-cli-screenshot.png) + or ```bash diff --git a/go.sum b/go.sum index ae2ce77..45fc4c7 100644 --- a/go.sum +++ b/go.sum @@ -12,18 +12,15 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/kmesiab/go-github-diff v0.1.0-alpha h1:Iq05K3nXD/iyh2RGTjKudmI5YDs/nI1I8+ChE27gcN8= github.com/kmesiab/go-github-diff v0.1.0-alpha/go.mod h1:eqE039Qx1HUnJ4hjLBPU9UHE+3KxbEmUOear9QcV12M= -github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -45,7 +42,6 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= @@ -58,14 +54,11 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= diff --git a/main.go b/main.go index 2323745..ef3f497 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,8 @@ func main() { os.Exit(cli.Run(new(argT), func(ctx *cli.Context) error { argv := ctx.Argv().(*argT) + printGreeting() + mergedArgs, err := coalesceConfiguration(argv) if err != nil { return fmt.Errorf("couldn't figure out the configuration. %s", err) @@ -40,14 +42,17 @@ func main() { "or set the OPENAI_API_KEY environment variable") } + fmt.Printf("šŸ“” Getting pull request from GitHub...\n") + parsedDiffFiles, err := processPullRequest(mergedArgs.URL, &GithubDiffClient{}) + if err != nil { return err } - fmt.Printf("Processing %d diff files. This may take a while...\n", len(parsedDiffFiles)) + fmt.Printf("\nāŒ› Processing %d diff files. This may take a while...\n\n", len(parsedDiffFiles)) - reviews, err := getCodeReviews(parsedDiffFiles, "gpt-4", mergedArgs.ApiKey, &OpenAICompletionService{}) + reviews, err := getCodeReviews(parsedDiffFiles, "gpt-4-1106-preview", mergedArgs.ApiKey, &OpenAICompletionService{}) if err != nil { return err } @@ -55,7 +60,7 @@ func main() { for _, review := range reviews { if review.Error != nil { - fmt.Printf("ERROR: couldn't get the review for %s: %s\n", + fmt.Printf("āš ļø couldn't get the review for %s: %s\n", path.Base(review.Diff.FilePathNew), review.Error, ) @@ -68,7 +73,7 @@ func main() { err := saveReviewToFile(filename, review.Review) if err != nil { - fmt.Printf("couldn't save the review for %s: %s", + fmt.Printf("āš ļø couldn't save the review for %s: %s\n", filename, err, ) @@ -76,18 +81,10 @@ func main() { continue } - fmt.Printf("Saved review to %s\n", filename) - - if err != nil { - fmt.Printf("couldn't save the review for %s: %s", - filename, - err, - ) - - continue - } + fmt.Printf("šŸ’¾ Saved review to %s\n", filename) } + fmt.Println("Done! šŸ") return nil })) } @@ -98,7 +95,7 @@ func getCodeReviews(diffs []*gh.GitDiff, model, apiKey string, svc CompletionSer for _, diff := range diffs { go func(d *gh.GitDiff) { - fmt.Printf("Processing %s\n", path.Base(d.FilePathNew)) + fmt.Printf("šŸ¤– Getting code review for %s\n", path.Base(d.FilePathNew)) review, err := svc.GetCompletion(d.DiffContents, model, apiKey) @@ -165,7 +162,6 @@ func saveReviewToFile(filename, reviewContent string) error { return fmt.Errorf("failed to write review to file: %s", err) } - fmt.Printf("Saved review to %s\n", filename) return nil } @@ -186,3 +182,15 @@ func coalesceConfiguration(cliArgs *argT) (*argT, error) { return cliArgs, nil } + +func printGreeting() { + fmt.Println(` + _____ ___ ____________ _____ +/ __ \ / _ \| _ \ ___ \ ___| +| / \// /_\ \ | | | |_/ / |__ +| | | _ | | | | /| __| +| \__/\| | | | |/ /| |\ \| |___ + \____/\_| |_/___/ \_| \_\____/ + + `) +}