Skip to content

Commit 02b96a1

Browse files
authored
Merge pull request #8 from DFanso/dev
feat: add automatic clipboard copy functionality
2 parents ef70edc + cda9558 commit 02b96a1

6 files changed

Lines changed: 27 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ go.work
2222
.env
2323
commit-helper.json
2424
HACKTOBERFEST_SETUP.md
25+
PR_DESCRIPTION.md

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ Looking to contribute? Check out:
2626
## Features
2727

2828
**AI-Powered Commit Messages** - Automatically generate meaningful commit messages
29-
🔄 **Multiple LLM Support** - Choose between Google Gemini or Grok
29+
🔄 **Multiple LLM Support** - Choose between Google Gemini, Grok, or ChatGPT
3030
📝 **Context-Aware** - Analyzes staged and unstaged changes
31-
🚀 **Easy to Use** - Simple CLI interface
31+
📋 **Auto-Copy to Clipboard** - Generated messages are automatically copied for instant use
32+
📊 **File Statistics Display** - Visual preview of changed files and line counts
33+
🚀 **Easy to Use** - Simple CLI interface with beautiful terminal UI
3234
**Fast** - Quick generation of commit messages
3335

3436
## Supported LLM Providers
@@ -39,9 +41,10 @@ You can use either **Google Gemini** or **Grok** as the LLM to generate commit m
3941

4042
| Variable | Values | Description |
4143
|----------|--------|-------------|
42-
| `COMMIT_LLM` | `gemini` or `grok` | Choose your LLM provider |
44+
| `COMMIT_LLM` | `gemini`, `grok`, or `chatgpt` | Choose your LLM provider |
4345
| `GEMINI_API_KEY` | Your API key | Required if using Gemini |
4446
| `GROK_API_KEY` | Your API key | Required if using Grok |
47+
| `OPENAI_API_KEY` | Your API key | Required if using ChatGPT |
4548

4649
---
4750

@@ -128,15 +131,22 @@ git add .
128131
# Generate commit message
129132
commit .
130133

134+
# The tool will display:
135+
# - File statistics (staged, unstaged, untracked)
136+
# - Generated commit message in a styled box
137+
# - Automatically copy to clipboard
131138
# Output: "feat: add hello world console log to app.js"
139+
# You can now paste it with Ctrl+V (or Cmd+V on macOS)
132140
```
133141

134142
### Use Cases
135143

136144
- 📝 Generate commit messages for staged changes
137145
- 🔍 Analyze both staged and unstaged changes
138-
- 📊 Get context from recent commits
146+
- 📊 Get context from recent commits and file statistics
139147
- ✅ Create conventional commit messages
148+
- 📋 Auto-copy to clipboard for immediate use
149+
- 🎨 Beautiful terminal UI with file statistics and previews
140150

141151
---
142152

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ require (
2121
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
2222
cloud.google.com/go/compute/metadata v0.6.0 // indirect
2323
cloud.google.com/go/longrunning v0.5.7 // indirect
24+
github.com/atotto/clipboard v0.1.4 // indirect
2425
github.com/containerd/console v1.0.5 // indirect
2526
github.com/felixge/httpsnoop v1.0.4 // indirect
2627
github.com/go-logr/logr v1.4.2 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ github.com/MarvinJWendt/testza v0.4.2/go.mod h1:mSdhXiKH8sg/gQehJ63bINcCKp7RtYew
2828
github.com/MarvinJWendt/testza v0.5.2 h1:53KDo64C1z/h/d/stCYCPY69bt/OSwjq5KpFNwi+zB4=
2929
github.com/MarvinJWendt/testza v0.5.2/go.mod h1:xu53QFE5sCdjtMCKk8YMQ2MnymimEctc4n3EjyIYvEY=
3030
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
31+
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
32+
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
3133
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
3234
github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc=
3335
github.com/containerd/console v1.0.5/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=

image.png

45.3 KB
Loading

src/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path/filepath"
99
"strings"
1010

11+
"github.com/atotto/clipboard"
1112
"github.com/dfanso/commit-msg/src/chatgpt"
1213
"github.com/dfanso/commit-msg/src/gemini"
1314
"github.com/dfanso/commit-msg/src/grok"
@@ -132,6 +133,14 @@ func main() {
132133
// Display the commit message in a styled panel
133134
displayCommitMessage(commitMsg)
134135

136+
// Copy to clipboard
137+
err = clipboard.WriteAll(commitMsg)
138+
if err != nil {
139+
pterm.Warning.Printf("⚠️ Could not copy to clipboard: %v\n", err)
140+
} else {
141+
pterm.Success.Println("📋 Commit message copied to clipboard!")
142+
}
143+
135144
pterm.Println()
136145

137146
// Display changes preview

0 commit comments

Comments
 (0)