From dcc02eb5fb303758e7c3a41e5b3819fd26a34ae6 Mon Sep 17 00:00:00 2001 From: WoutVossen Date: Mon, 16 Sep 2024 20:09:39 +0200 Subject: [PATCH 1/3] minor change --- cmd/bundle.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/bundle.go b/cmd/bundle.go index 03fa22f..32e89bf 100644 --- a/cmd/bundle.go +++ b/cmd/bundle.go @@ -148,9 +148,9 @@ crev bundle --ignore-pre=tests,readme --include-ext=.go,.py,.js func init() { rootCmd.AddCommand(generateCmd) // TODO Fix description with defaults - generateCmd.Flags().StringSlice("ignore-pre", []string{}, "Comma-separated prefixes of paths to ignore. Ex \"tests,readme\"") - generateCmd.Flags().StringSlice("ignore-ext", []string{}, "Comma-separated file extensions to ignore. Ex \".txt\"") - generateCmd.Flags().StringSlice("include-ext", []string{}, "Comma-separated file extensions to include. Ex \".go,.py,.js\"") + generateCmd.Flags().StringSlice("ignore-pre", []string{}, "Comma-separated prefixes of paths to ignore. Ex tests,readme") + generateCmd.Flags().StringSlice("ignore-ext", []string{}, "Comma-separated file extensions to ignore. Ex .txt,.md") + generateCmd.Flags().StringSlice("include-ext", []string{}, "Comma-separated file extensions to include. Ex .go,.py,.js") err := viper.BindPFlag("ignore-pre", generateCmd.Flags().Lookup("ignore-pre")) if err != nil { log.Fatal(err) From dadb3b8c837c4b75d00fb84c17a5647bcc2f3047 Mon Sep 17 00:00:00 2001 From: WoutVossen Date: Mon, 16 Sep 2024 20:22:19 +0200 Subject: [PATCH 2/3] Update ignore-pre docstring --- cmd/bundle.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/bundle.go b/cmd/bundle.go index 32e89bf..a32ecaf 100644 --- a/cmd/bundle.go +++ b/cmd/bundle.go @@ -148,7 +148,7 @@ crev bundle --ignore-pre=tests,readme --include-ext=.go,.py,.js func init() { rootCmd.AddCommand(generateCmd) // TODO Fix description with defaults - generateCmd.Flags().StringSlice("ignore-pre", []string{}, "Comma-separated prefixes of paths to ignore. Ex tests,readme") + generateCmd.Flags().StringSlice("ignore-pre", []string{}, "Comma-separated prefixes of file and dir names to ignore. Ex tests,readme") generateCmd.Flags().StringSlice("ignore-ext", []string{}, "Comma-separated file extensions to ignore. Ex .txt,.md") generateCmd.Flags().StringSlice("include-ext", []string{}, "Comma-separated file extensions to include. Ex .go,.py,.js") err := viper.BindPFlag("ignore-pre", generateCmd.Flags().Lookup("ignore-pre")) From 917a8b133838bb56e0627869b5b1bafd267c9b90 Mon Sep 17 00:00:00 2001 From: WoutVossen Date: Sun, 22 Sep 2024 15:46:34 +0200 Subject: [PATCH 3/3] Add loading api key through env var --- .crev-config.yaml | 9 --------- cmd/init.go | 5 +++-- cmd/review.go | 10 +++++----- readme.md | 25 ++++++++++++++----------- 4 files changed, 22 insertions(+), 27 deletions(-) delete mode 100644 .crev-config.yaml diff --git a/.crev-config.yaml b/.crev-config.yaml deleted file mode 100644 index f3deebc..0000000 --- a/.crev-config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Configuration for the crev tool -# specify your Code AI Review API key (necessary for review command) -api-key: # Fill in your CREV API key here -# specify the prefixes of files and directories to ignore (by default common configuration files are ignored) -ignore-pre: # ex. [tests, readme.md, scripts] -# specify the extensions of files to ignore -ignore-ext: [.go, .py, .js, .txt] -# specify the extensions of files to include -include-ext: # ex. [.go, .py, .js] diff --git a/cmd/init.go b/cmd/init.go index 4ba4d18..bcbe353 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -11,8 +11,9 @@ import ( // Define a default template configuration var defaultConfig = []byte(`# Configuration for the crev tool -# specify your Code AI Review API key (necessary for review command) -api-key: # Fill in your CREV API key here + +# specify your CREV API key (necessary for review command) ! this overwrites the value you specify in the environment variable +crev_api_key: # ex. csk_8e796a8f6fdb15f0902eee0d4138b9d5975e244e6cc61ef302feaf37af24c7cb # specify the prefixes of files and directories to ignore (by default common configuration files are ignored) ignore-pre: # ex. [tests, readme.md, scripts] # specify the extensions of files to ignore diff --git a/cmd/review.go b/cmd/review.go index 4328a1c..0cf23a8 100644 --- a/cmd/review.go +++ b/cmd/review.go @@ -20,13 +20,13 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - apiKey := viper.GetString("api-key") + apiKey := viper.GetString("crev_api_key") if apiKey == "" { - log.Fatal(`API key is required for this command. Set the API key under the 'api-key' key in your .crev-config.yaml or provide it as a flag --api-key.`) + log.Fatal(`Api key is required for review. Generate yours on: ... and set it as CREV_API_KEY env var or specify it under 'crev_api_key' key in your .crev-config.yaml. For more information see: ...`) } dat, err := os.ReadFile(".crev-project-overview.txt") if err != nil { - log.Fatal(err) + log.Fatal("Could not find .crev-project-overview.txt. Did you generate it using \"crev bundle\" command?") } review.Review(string(dat), apiKey) }, @@ -34,8 +34,8 @@ to quickly create a Cobra application.`, func init() { rootCmd.AddCommand(reviewCmd) - reviewCmd.Flags().String("api-key", "", "Your Code AI Review API key ") - err := viper.BindPFlag("api-key", reviewCmd.Flags().Lookup("api-key")) + reviewCmd.Flags().String("crev_api_key", "", "Your Code AI Review API key ") + err := viper.BindPFlag("crev_api_key", reviewCmd.Flags().Lookup("crev_api_key")) if err != nil { log.Fatal(err) } diff --git a/readme.md b/readme.md index 42be4af..15758e3 100644 --- a/readme.md +++ b/readme.md @@ -2,28 +2,31 @@ CLI tool to review code using AI. -## installation -Linux/MacOS binaries -```bash -sudo curl -L https://raw.githubusercontent.com/vossenwout/crev/feature/add-install-scripts/scripts/install.sh | bash -``` +## Installation + Brew (MacOS / Linux) ```bash brew install vossenwout/crev/crev ``` - -windows (Run as Administrator in powershell) -```bash -Invoke-Expression (Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/vossenwout/crev/feature/add-install-scripts/scripts/install.ps1').Content -``` -Scoop +Scoop (Windows) ```bash scoop bucket add crev https://github.com/vossenwout/scoop-crev ``` ```bash scoop install crev ``` +Linux/MacOS binaries +```bash +sudo curl -L https://raw.githubusercontent.com/vossenwout/crev/feature/add-install-scripts/scripts/install.sh | bash +``` +Windows binaries (Run as Administrator in powershell) +```bash +Invoke-Expression (Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/vossenwout/crev/feature/add-install-scripts/scripts/install.ps1').Content +``` + + + ## Releasing Push a new tag to the repository. ```bash