From e80ef7b4845a498cc490810cae2dbadaa5bfc7ef Mon Sep 17 00:00:00 2001 From: Carlos Castro Date: Sun, 31 Mar 2024 14:32:15 +0100 Subject: [PATCH] Add to clipboard --- .github/workflows/ci.yaml | 2 +- go.mod | 6 +++++- go.sum | 8 ++++++++ pkg/output/messages.go | 9 +++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e08b9d8..ee13f9f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.19 + go-version: 1.23 - name: Verify dependencies run: go mod verify diff --git a/go.mod b/go.mod index 3404f77..18009ea 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/carloscastrojumo/remindme -go 1.19 +go 1.23.0 require ( github.com/adrg/xdg v0.4.0 @@ -10,6 +10,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 go.mongodb.org/mongo-driver v1.14.0 + golang.design/x/clipboard v0.7.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -40,6 +41,9 @@ require ( go.uber.org/multierr v1.9.0 // indirect golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/exp/shiny v0.0.0-20240325151524-a685a6edb6d8 // indirect + golang.org/x/image v0.14.0 // indirect + golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/go.sum b/go.sum index 4dc9aae..5c47586 100644 --- a/go.sum +++ b/go.sum @@ -87,12 +87,20 @@ go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.design/x/clipboard v0.7.0 h1:4Je8M/ys9AJumVnl8m+rZnIvstSnYj1fvzqYrU3TXvo= +golang.design/x/clipboard v0.7.0/go.mod h1:PQIvqYO9GP29yINEfsEn5zSQKAz3UgXmZKzDA6dnq2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp/shiny v0.0.0-20240325151524-a685a6edb6d8 h1:GYlVE/zmuKm+XvR3nYWXZF0SaO2vvPX1Djy2LVOf+TU= +golang.org/x/exp/shiny v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o= +golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= +golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= +golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a h1:sYbmY3FwUWCBTodZL1S3JUuOvaW6kM2o+clDzzDNBWg= +golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a/go.mod h1:Ede7gF0KGoHlj822RtphAHK1jLdrcuRBZg0sF1Q+SPc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= diff --git a/pkg/output/messages.go b/pkg/output/messages.go index 53579e1..80a5c95 100644 --- a/pkg/output/messages.go +++ b/pkg/output/messages.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/fatih/color" + "golang.design/x/clipboard" ) // Note note struct @@ -39,6 +40,14 @@ func Print(note interface{}) { maxLength := getMaxLength(orderedNotes) numberOfNotes := len(orderedNotes) + if numberOfNotes == 1 { + err := clipboard.Init() + if err != nil { + color.Red("Error while initializing clipboard: %s", err) + } + clipboard.Write(clipboard.FmtText, []byte(orderedNotes[0].Notes[0].Command)) + } + for _, orderedNote := range orderedNotes { numberOfNotes-- size := 20