feat: copy to clipboard
This commit is contained in:
parent
1ea179408f
commit
c8c094854c
5
go.mod
5
go.mod
@ -2,4 +2,7 @@ module github.com/jabuxas/revelation
|
|||||||
|
|
||||||
go 1.23.4
|
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
|
||||||
|
)
|
||||||
|
2
go.sum
2
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 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
|
@ -9,13 +9,19 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/atotto/clipboard"
|
||||||
)
|
)
|
||||||
|
|
||||||
const pasteURL = "https://paste.jabuxas.com"
|
var pasteURL = os.Getenv("PASTEBIN_URL")
|
||||||
|
|
||||||
var key = os.Getenv("AUTH_KEY")
|
var key = os.Getenv("AUTH_KEY")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if pasteURL == "" || key == "" {
|
||||||
|
fmt.Println("Please set PASTEBIN_URL and AUTH_KEY environment variables")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
file := strings.Split(SelectFile(), "file://")[1]
|
file := strings.Split(SelectFile(), "file://")[1]
|
||||||
request, err := uploadFile(file)
|
request, err := uploadFile(file)
|
||||||
|
|
||||||
@ -33,7 +39,10 @@ func main() {
|
|||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
respBody, _ := io.ReadAll(res.Body)
|
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) {
|
func uploadFile(file string) (*http.Request, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user