Skip to content

Commit

Permalink
BREAKING CHANGE: v1 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradumnasaraf authored Jul 2, 2024
1 parent f824fd4 commit da8baad
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 40 deletions.
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# GenCLI
## GenCLI

<div align="center">

[![Releases](https://github.com/Pradumnasaraf/gencli/actions/workflows/releases.yml/badge.svg)](https://github.com/Pradumnasaraf/gencli/actions/workflows/releases.yml) [![Go Reference](https://pkg.go.dev/badge/github.com/Pradumnasaraf/gencli.svg)](https://pkg.go.dev/github.com/Pradumnasaraf/gencli)

</div>

**GenCLI** is a AI-powered CLI tool that knows answers to all your questions. It is built with [Go](https://github.com/golang/go), [Cobra](https://github.com/spf13/cobra), [Viper](https://github.com/spf13/viper), [Gemini](https://gemini.google.com), etc.
**GenCLI** is an AI-powered CLI tool built with Golang that answers your questions using the [Google Gemini API](https://gemini.google.com). It is developed with [Cobra](https://github.com/spf13/cobra), [Viper](https://github.com/spf13/viper), and more.

### 🚀 Getting Started

## 🚀 Getting Started
To get started with GenCLI, you can install it using the following method:

To get started with GenCLI, you can install it using the following methods:
#### Installation

To install the CLI, use the command below:

Expand All @@ -21,30 +22,31 @@ go install github.com/Pradumnasaraf/gencli@latest

Go will automatically install it in your `$GOPATH/bin` directory, which should be in your `$PATH`.

#### Usage

Once installed, you can use the `gencli` CLI command. To confirm installation, type `gencli` at the command line.

As it uses the Google Gemini API to we need to set the API key. To get the API key (It's FREE), you need to visit [here](https://aistudio.google.com/app/apikey?_gl=1*1n5ijhw*_ga*MTQxNDQ2MjcyNi4xNzE5MDU4OTE0*_ga_P1DBVKWT6V*MTcxOTkzNTQzOC4zLjEuMTcxOTkzNTQ3My4yNS4wLjEzODczMjU2OA) and set it in the environment variable `GENCLI_API_KEY`.
GenCLI uses the Google Gemini API, so you need to set the API key. To get the API key (It's FREE), visit [here](https://aistudio.google.com/app/apikey?_gl=1*1n5ijhw*_ga*MTQxNDQ2MjcyNi4xNzE5MDU4OTE0*_ga_P1DBVKWT6V*MTcxOTkzNTQzOC4zLjEuMTcxOTkzNTQ3My4yNS4wLjEzODczMjU2OA) and set it in the environment variable `GEMINI_API_KEY`:

```bash
export GENCLI_API_KEY=<API_KEY>
export GEMINI_API_KEY=<API_KEY>
```

Above method will set the API key for the current session only. To set it permanently, you can add the above line to your `.bashrc` or `.zshrc` file.
The above method sets the API key for the current session only. To set it permanently, add the above line to your `.bashrc` or `.zshrc` file.

> **Note:** If you encounter the error `command not found: gencli`, you need to add `$GOPATH/bin` to your `$PATH` environment variable. For more details, refer to [this guide](https://gist.github.com/Pradumnasaraf/ca6f9a0507089a4c44881446cdda4aa3).
> **Note** If you are getting an error like `command not found: gencli`, then you need to add `$GOPATH/bin` to your `$PATH` environment variable. For that you can refer to [this](https://gist.github.com/Pradumnasaraf/ca6f9a0507089a4c44881446cdda4aa3).
#### Commands

```
Usage:
gencli [command]
Available Commands:
gencli Type your question here
gencli [your question] [flags]
```

## 📜 License
### 📜 License

This project is licensed under the Apache-2.0 license - see the [LICENSE](LICENSE) file for details.

## 🛡 Security
### 🛡 Security

If you discover a security vulnerability within this project, please check the [SECURITY](SECURITY.md) for more information.
If you discover a security vulnerability within this project, please check the [SECURITY](SECURITY.md) for more information.
9 changes: 3 additions & 6 deletions cmd/rootCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import (
"os"
"strings"

"github.com/Pradumnasaraf/gencli/config"
"github.com/google/generative-ai-go/genai"
"github.com/spf13/cobra"
"google.golang.org/api/option"
)

var rootCmd = &cobra.Command{
Use: "gencli",
Short: "Ask me anything :)",
Use: "gencli [your question]",
Short: "A CLI tool to interact with the Gemini API",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
res := getApiRespone(args)
Expand All @@ -32,13 +31,11 @@ func Execute() {

func getApiRespone(args []string) string {

// Load the environment variables
config.Config()

userArgs := strings.Join(args[1:], " ")

ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY")))

if err != nil {
log.Fatal(err)
}
Expand Down
15 changes: 0 additions & 15 deletions config/root.go

This file was deleted.

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.22

require (
github.com/google/generative-ai-go v0.14.0
github.com/joho/godotenv v1.5.1
github.com/spf13/cobra v1.8.1
google.golang.org/api v0.185.0
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ github.com/googleapis/gax-go/v2 v2.12.4 h1:9gWcmF85Wvq4ryPFvGFaOgPIs1AQX0d0bcbGw
github.com/googleapis/gax-go/v2 v2.12.4/go.mod h1:KYEYLorsnIGDi/rPC8b5TdlB9kbKoFubselGIoBMCwI=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
package main

import (
"fmt"
"os"

"github.com/Pradumnasaraf/gencli/cmd"
)

func main() {

geminiAPIKey := os.Getenv("GEMINI_API_KEY")

if geminiAPIKey == "" {
fmt.Println("Please set the GEMINI_API_KEY environment variable. Check the README for more information.")
return
}

// Execute the root command
cmd.Execute()

}

0 comments on commit da8baad

Please sign in to comment.