-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (38 loc) · 1 KB
/
main.go
File metadata and controls
50 lines (38 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"context"
"flag"
"fmt"
"io"
"os"
"go.lsp.dev/jsonrpc2"
"github.com/mcncl/buildkite-ls/internal/lsp"
)
var (
// Version information - set during build
version = "dev"
commit = "none"
date = "unknown"
)
type stdio struct{}
func (stdio) Read(p []byte) (n int, err error) { return os.Stdin.Read(p) }
func (stdio) Write(p []byte) (n int, err error) { return os.Stdout.Write(p) }
func (stdio) Close() error { return nil }
func main() {
showVersion := flag.Bool("version", false, "Show version information")
flag.Parse()
if *showVersion {
fmt.Printf("buildkite-ls %s\n", version)
fmt.Printf("Commit: %s\n", commit)
fmt.Printf("Built: %s\n", date)
return
}
server := lsp.NewServer()
var rw io.ReadWriteCloser = stdio{}
stream := jsonrpc2.NewStream(rw)
conn := jsonrpc2.NewConn(stream)
// Set the connection in the server so it can send notifications
server.SetConnection(conn)
go conn.Go(context.Background(), server.Handler())
<-conn.Done()
}