Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmd/nubi.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"syscall"
"time"

"github.com/atotto/clipboard"
"github.com/briandowns/spinner"
"github.com/c-bata/go-prompt"
"github.com/charmbracelet/glamour"
Expand All @@ -35,6 +36,7 @@ var suggestions = []prompt.Suggest{
{Text: "/agents", Description: "List available agents"},
{Text: "/tools", Description: "List available tools"},
{Text: "/functions", Description: "List available functions"},
{Text: "/copy", Description: "Copy the last response to clipboard"},
{Text: "/exit", Description: "Exit the Nubi shell"},
}

Expand Down Expand Up @@ -159,6 +161,7 @@ type nubiShell struct {
history []string
waitingMessageID string
waitingAgentID string
lastResponse string
}

type MessageConfig struct {
Expand Down Expand Up @@ -239,6 +242,8 @@ func (s *nubiShell) executor(in string) {
return
}

s.lastResponse = response

if status == "WAITING" {
fmt.Println(response)
} else {
Expand Down Expand Up @@ -414,6 +419,16 @@ func (s *nubiShell) handleSlashCommand(in string) {
{Header: "VARIABLES", Field: "Variables"},
},
})
case "/copy":
if s.lastResponse == "" {
fmt.Println("Nothing to copy.")
return
}
if err := clipboard.WriteAll(s.lastResponse); err != nil {
fmt.Printf("Error copying to clipboard: %v\n", err)
} else {
fmt.Println("Copied to clipboard!")
}
case "/exit":
fmt.Println("Goodbye!")
os.Exit(0)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/nudgebee/nbctl
go 1.25.1

require (
github.com/atotto/clipboard v0.1.4
github.com/briandowns/spinner v1.23.2
github.com/c-bata/go-prompt v0.2.6
github.com/charmbracelet/glamour v0.10.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46
github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
Expand Down