From 1710186019c2cd717c896fdc85036e188604e4ff Mon Sep 17 00:00:00 2001 From: Remi Salmon Date: Tue, 24 Sep 2024 19:35:00 -0600 Subject: [PATCH 1/4] Cleanup dependencies --- go.mod | 10 ++++------ go.sum | 6 ++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index efa69f3dc6..16a303b30d 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require ( github.com/jackc/pgx/v5 v5.6.0 github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 github.com/jmrobles/h2go v0.5.0 + github.com/kenshaw/colors v0.1.6 github.com/kenshaw/rasterm v0.1.10 github.com/lib/pq v1.10.9 github.com/marcboeker/go-duckdb v1.7.0 @@ -58,8 +59,9 @@ require ( github.com/trinodb/trino-go-client v0.315.0 github.com/uber/athenadriver v1.1.15 github.com/vertica/vertica-sql-go v1.3.3 - github.com/xo/chartfmt v0.0.0 github.com/xo/dburl v0.23.2 + github.com/xo/echartsgoja v0.1.1 + github.com/xo/resvg v0.6.0 github.com/xo/tblfmt v0.13.2 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e github.com/ydb-platform/ydb-go-sdk/v3 v3.75.2 @@ -235,6 +237,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jonboulle/clockwork v0.4.0 // indirect github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect + github.com/kenshaw/snaker v0.2.0 // indirect github.com/klauspost/asmfmt v1.3.2 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect @@ -296,9 +299,6 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - github.com/xo/echartsgoja v0.1.1 // indirect - github.com/xo/resvg v0.6.0 // indirect - github.com/xo/vegagoja v0.1.0 // indirect github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 // indirect github.com/ydb-platform/ydb-go-genproto v0.0.0-20240528144234-5d5a685e41f7 // indirect github.com/zeebo/xxh3 v1.0.2 // indirect @@ -355,5 +355,3 @@ require ( modernc.org/token v1.1.0 // indirect modernc.org/zappy v1.1.0 // indirect ) - -replace github.com/xo/chartfmt => ../chartfmt diff --git a/go.sum b/go.sum index fa2563baa5..f2ba70f8ea 100644 --- a/go.sum +++ b/go.sum @@ -1266,8 +1266,12 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/kenshaw/colors v0.1.6 h1:saSe9+ubchrnwWqwfNIP5CLEQcGcFp3vgiag2g538jk= +github.com/kenshaw/colors v0.1.6/go.mod h1:+Nx5c4s70YO6elThBFOk0/9InGOvV1+uAak7T29sCKk= github.com/kenshaw/rasterm v0.1.10 h1:cMCTpBHfqmftt/VqeT6B+9Td+mYi+ZtziN+XBdrTQfA= github.com/kenshaw/rasterm v0.1.10/go.mod h1:kL4DCN+wOlQ4BPBCxA+itiVwiObRAj0Hkze7SbCyYaw= +github.com/kenshaw/snaker v0.2.0 h1:DPlxCtAv9mw1wSsvIN1khUAPJUIbFJUckMIDWSQ7TC8= +github.com/kenshaw/snaker v0.2.0/go.mod h1:DNyRUqHMZ18/zioxr6R7m4kSxxf2+QmB0BXoORsXRaY= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= @@ -1536,8 +1540,6 @@ github.com/xo/tblfmt v0.13.2 h1:GzHsRYduJxKqwNekczv2ZJwpznsSU89Dr2L+qVyW63Y= github.com/xo/tblfmt v0.13.2/go.mod h1:BLPC+dRy68cgSK/mPgQRfFQ/xLg231Fyic178ybjB34= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= -github.com/xo/vegagoja v0.1.0 h1:jnIeXVM6HTzWyt2HHmJMkhgK1zjZMIdhdI+MBFjkF54= -github.com/xo/vegagoja v0.1.0/go.mod h1:2DGNf2X4fnAw2h5zSVIdF1inbmEpoE+rSbzzYBYjTAY= github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 h1:zzrxE1FKn5ryBNl9eKOeqQ58Y/Qpo3Q9QNxKHX5uzzQ= github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2/go.mod h1:hzfGeIUDq/j97IG+FhNqkowIyEcD88LrW6fyU3K3WqY= github.com/ydb-platform/ydb-go-genproto v0.0.0-20240528144234-5d5a685e41f7 h1:nL8XwD6fSst7xFUirkaWJmE7kM0CdWRYgu6+YQer1d4= From 1c33a7e1cb7ab37fdc688db7fd84d8576927c4f4 Mon Sep 17 00:00:00 2001 From: Remi Salmon Date: Tue, 24 Sep 2024 19:35:13 -0600 Subject: [PATCH 2/4] Add back drivers completer in handler --- handler/handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/handler/handler.go b/handler/handler.go index ba9a24a2fc..0422e0a6e9 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -783,6 +783,7 @@ func (h *Handler) Open(ctx context.Context, params ...string) error { // force error/check connection if err == nil { if err = drivers.Ping(ctx, h.u, h.db); err == nil { + h.l.Completer(drivers.NewCompleter(ctx, h.u, h.db, readerOpts(), completer.WithConnStrings(h.connStrings()))) return h.Version(ctx) } } From c0940a3a766548f81f4915edf9d6284a867d8e1a Mon Sep 17 00:00:00 2001 From: Remi Salmon Date: Wed, 25 Sep 2024 22:22:09 -0600 Subject: [PATCH 3/4] Set drivers completions when interactive only --- handler/handler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/handler/handler.go b/handler/handler.go index 0422e0a6e9..023d0d4b1f 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -783,7 +783,9 @@ func (h *Handler) Open(ctx context.Context, params ...string) error { // force error/check connection if err == nil { if err = drivers.Ping(ctx, h.u, h.db); err == nil { - h.l.Completer(drivers.NewCompleter(ctx, h.u, h.db, readerOpts(), completer.WithConnStrings(h.connStrings()))) + if h.l.Interactive() { + h.l.Completer(drivers.NewCompleter(ctx, h.u, h.db, readerOpts(), completer.WithConnStrings(h.connStrings()))) + } return h.Version(ctx) } } From 2ad11cf41940e3fb14f5246e0c63796e5d45d286 Mon Sep 17 00:00:00 2001 From: Remi Salmon Date: Wed, 25 Sep 2024 22:25:04 -0600 Subject: [PATCH 4/4] Move completer calls to handler open --- handler/handler.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/handler/handler.go b/handler/handler.go index 023d0d4b1f..b289888d30 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -109,10 +109,6 @@ func New(l rline.IO, user *user.User, wd string, charts billy.Filesystem, nopw b nopw: nopw, buf: stmt.New(f), } - if iactive { - l.SetOutput(h.outputHighlighter) - l.Completer(completer.NewDefaultCompleter(completer.WithConnStrings(h.connStrings()))) - } return h } @@ -784,6 +780,8 @@ func (h *Handler) Open(ctx context.Context, params ...string) error { if err == nil { if err = drivers.Ping(ctx, h.u, h.db); err == nil { if h.l.Interactive() { + h.l.SetOutput(h.outputHighlighter) + h.l.Completer(completer.NewDefaultCompleter(completer.WithConnStrings(h.connStrings()))) h.l.Completer(drivers.NewCompleter(ctx, h.u, h.db, readerOpts(), completer.WithConnStrings(h.connStrings()))) } return h.Version(ctx)