From c8c094854c2f5cb651d76db6227a1b0779df4564 Mon Sep 17 00:00:00 2001 From: jabuxas Date: Thu, 27 Feb 2025 13:58:54 -0300 Subject: [PATCH] feat: copy to clipboard --- go.mod | 5 ++++- go.sum | 2 ++ revelation.go | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 3b91c69..69cfa1b 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/jabuxas/revelation go 1.23.4 -require github.com/godbus/dbus/v5 v5.1.0 // indirect +require ( + github.com/atotto/clipboard v0.1.4 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect +) diff --git a/go.sum b/go.sum index 024b269..48e7411 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ +github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= +github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= diff --git a/revelation.go b/revelation.go index cf26f6c..cd50961 100644 --- a/revelation.go +++ b/revelation.go @@ -9,13 +9,19 @@ import ( "os" "path" "strings" + + "github.com/atotto/clipboard" ) -const pasteURL = "https://paste.jabuxas.com" - +var pasteURL = os.Getenv("PASTEBIN_URL") var key = os.Getenv("AUTH_KEY") func main() { + if pasteURL == "" || key == "" { + fmt.Println("Please set PASTEBIN_URL and AUTH_KEY environment variables") + return + } + file := strings.Split(SelectFile(), "file://")[1] request, err := uploadFile(file) @@ -33,7 +39,10 @@ func main() { defer res.Body.Close() respBody, _ := io.ReadAll(res.Body) - fmt.Println(string(respBody)) + + if err := clipboard.WriteAll(string(respBody)); err != nil { + panic(err) + } } func uploadFile(file string) (*http.Request, error) {