04711cf7b2
* update error handling in various commands to use blank identifier * enhance output formatting for better readability * add golangci-lint to Makefile for linting checks
29 lines
569 B
Go
29 lines
569 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"git.warky.dev/wdevs/pgtidy/pkg/lsp"
|
|
)
|
|
|
|
func cmdLsp(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
|
|
for _, a := range args {
|
|
if a == "-h" || a == "--help" {
|
|
_, _ = fmt.Fprintln(stdout, "pgtidy lsp — start the Language Server Protocol server (stdio transport)")
|
|
return 0
|
|
}
|
|
}
|
|
wd, err := os.Getwd()
|
|
if err != nil {
|
|
wd = "."
|
|
}
|
|
if err := lsp.Serve(context.Background(), stdin, stdout, wd); err != nil {
|
|
_, _ = fmt.Fprintf(stderr, "pgtidy lsp: %v\n", err)
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|