Skip to content

Commit 92578a6

Browse files
Merge pull request #20 from open-olive/SIDE-980-whisper-ldk-new-list-whisper-type
Side 980 whisper ldk new list whisper type
2 parents 57a79e5 + 6be6c57 commit 92578a6

File tree

148 files changed

+25086
-1017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+25086
-1017
lines changed

ldk/go/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ test-examples:
3939
cd examples/storage && make test
4040
cd examples/whisper-confirm && make test
4141
cd examples/whisper-form && make test
42+
cd examples/whisper-list && make test
4243
cd examples/whisper-markdown && make test
4344

4445
test: test-examples

ldk/go/clipboardServer.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ type ClipboardServer struct {
1515

1616
// ClipboardRead is used by plugins to get the value of an entry
1717
func (m *ClipboardServer) ClipboardRead(ctx context.Context, req *proto.ClipboardReadRequest) (*proto.ClipboardReadResponse, error) {
18+
session, err := NewSessionFromProto(req.Session)
19+
if err != nil {
20+
return nil, err
21+
}
22+
1823
value, err := m.Impl.Read(
19-
context.WithValue(ctx, Session{}, NewSessionFromProto(req.Session)),
24+
context.WithValue(ctx, Session{}, session),
2025
)
2126
if err != nil {
2227
return nil, err
@@ -29,6 +34,11 @@ func (m *ClipboardServer) ClipboardRead(ctx context.Context, req *proto.Clipboar
2934

3035
// ClipboardReadStream is used by plugins to get the value of an entry
3136
func (m *ClipboardServer) ClipboardReadStream(req *proto.ClipboardReadStreamRequest, stream proto.Clipboard_ClipboardReadStreamServer) error {
37+
session, err := NewSessionFromProto(req.Session)
38+
if err != nil {
39+
return err
40+
}
41+
3242
handler := func(text string, err error) {
3343
var errText string
3444
if err != nil {
@@ -45,7 +55,7 @@ func (m *ClipboardServer) ClipboardReadStream(req *proto.ClipboardReadStreamRequ
4555

4656
go func() {
4757
err := m.Impl.Listen(
48-
context.WithValue(stream.Context(), Session{}, NewSessionFromProto(req.Session)),
58+
context.WithValue(stream.Context(), Session{}, session),
4959
handler,
5060
)
5161
// TODO: move this to a real logger once we move this into sidekick
@@ -62,8 +72,13 @@ func (m *ClipboardServer) ClipboardReadStream(req *proto.ClipboardReadStreamRequ
6272

6373
// ClipboardWrite is used by plugins to set an entry
6474
func (m *ClipboardServer) ClipboardWrite(ctx context.Context, req *proto.ClipboardWriteRequest) (*emptypb.Empty, error) {
65-
err := m.Impl.Write(
66-
context.WithValue(ctx, Session{}, NewSessionFromProto(req.Session)),
75+
session, err := NewSessionFromProto(req.Session)
76+
if err != nil {
77+
return nil, err
78+
}
79+
80+
err = m.Impl.Write(
81+
context.WithValue(ctx, Session{}, session),
6782
req.Text,
6883
)
6984
if err != nil {

ldk/go/cursorServer.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ type CursorServer struct {
1212
}
1313

1414
func (c *CursorServer) CursorPosition(ctx context.Context, req *proto.CursorPositionRequest) (*proto.CursorPositionResponse, error) {
15+
session, err := NewSessionFromProto(req.Session)
16+
if err != nil {
17+
return nil, err
18+
}
19+
1520
value, err := c.Impl.Position(
16-
context.WithValue(ctx, Session{}, NewSessionFromProto(req.Session)),
21+
context.WithValue(ctx, Session{}, session),
1722
)
1823
if err != nil {
1924
return nil, err
@@ -26,6 +31,11 @@ func (c *CursorServer) CursorPosition(ctx context.Context, req *proto.CursorPosi
2631
}
2732

2833
func (c *CursorServer) CursorPositionStream(req *proto.CursorPositionStreamRequest, stream proto.Cursor_CursorPositionStreamServer) error {
34+
session, err := NewSessionFromProto(req.Session)
35+
if err != nil {
36+
return err
37+
}
38+
2939
handler := func(msg CursorPosition, err error) {
3040
var errText string
3141
if err != nil {
@@ -43,7 +53,7 @@ func (c *CursorServer) CursorPositionStream(req *proto.CursorPositionStreamReque
4353

4454
go func() {
4555
err := c.Impl.ListenPosition(
46-
context.WithValue(stream.Context(), Session{}, NewSessionFromProto(req.Session)),
56+
context.WithValue(stream.Context(), Session{}, session),
4757
handler,
4858
)
4959
if err != nil {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Olive
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
REPO := github.com/open-olive/loop-development-kit/ldk/go/examples/whisper-list
2+
PKG := examplego
3+
4+
GIT_COMMIT := $(shell git rev-list -1 HEAD)
5+
GIT_BRANCH := $(if $(shell echo $$BRANCH_NAME),$(shell echo $$BRANCH_NAME),$(shell git rev-parse --abbrev-ref HEAD))
6+
VERSION := $(if $(shell echo $$VERSION),$(shell echo $$VERSION),"0.0.0-localdev-unset")
7+
GOPATH := $(shell go env GOPATH)
8+
9+
install:
10+
# The following command is needed to allow go get to clone from private bitbucket repos
11+
@ git config --global url."[email protected]:".insteadOf "https://bitbucket.org/"
12+
go mod download
13+
go mod tidy
14+
15+
build/darwin-amd64/plugin:
16+
go build \
17+
-ldflags "-X ${REPO}/loop.GitBranch=${GIT_BRANCH} -X ${REPO}/loop.GitCommit=${GIT_COMMIT} -X ${REPO}/loop.Version=${VERSION}" \
18+
-o build/darwin-amd64/plugin ./
19+
20+
build/windows-amd64/plugin:
21+
GOOS=windows go build \
22+
-ldflags "-X ${REPO}/loop.GitBranch=${GIT_BRANCH} -X ${REPO}/loop.GitCommit=${GIT_COMMIT} -X ${REPO}/loop.Version=${VERSION}" \
23+
-o build/windows-amd64/plugin.exe ./
24+
25+
clean:
26+
rm -rf ./build
27+
28+
build: clean build/darwin-amd64/plugin build/windows-amd64/plugin
29+
30+
# TODO: remove before merging to master
31+
deploy-local: build
32+
cp build/darwin-amd64/plugin ~/Library/Application\ Support/Olive\ Helps/loops/1/plugin
33+
34+
test:
35+
go test -v ./...
36+
37+
test-race:
38+
go test -v -race ./...
39+
40+
bench:
41+
go test -v -bench=. ./...
42+
43+
golangci:
44+
go get github.com/golangci/golangci-lint/cmd/[email protected]
45+
go mod tidy
46+
golangci-lint run
47+
48+
.PHONY: install build clean lint test test-race bench golangci
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/open-olive/loop-development-kit/ldk/go/examples/whisper-list
2+
3+
go 1.14
4+
5+
replace github.com/open-olive/loop-development-kit/ldk/go => ../..
6+
7+
require (
8+
github.com/google/go-cmp v0.5.2
9+
github.com/open-olive/loop-development-kit/ldk/go v0.0.0-00010101000000-000000000000
10+
)

0 commit comments

Comments
 (0)