branch: externals/drepl
commit 0ea5447442f8d6d24f70b8987249265fd9b6a0fd
Author: Augusto Stoffel <[email protected]>
Commit: Augusto Stoffel <[email protected]>
Make collection of usql drivers customizable
---
drepl-usql.el | 23 +++++++++++++++++++----
drepl-usql/drepl-usql.go | 9 ---------
drepl-usql/drivers.go | 11 +++++++++++
drepl-usql/go.mod | 10 ++++++++++
drepl-usql/go.sum | 5 +++++
5 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/drepl-usql.el b/drepl-usql.el
index b251e5b7a0..70635e34cd 100644
--- a/drepl-usql.el
+++ b/drepl-usql.el
@@ -49,13 +49,26 @@
"Name of the drepl-usql executable."
:type 'string)
+(defcustom drepl-usql-drivers
+ '(clickhouse csvq mysql oracle postgres sqlite3 sqlserver)
+ "List of drivers to include when building the `drepl-usql' executable.
+See https://github.com/xo/usql#database-support for the available
+options (second column of the table).
+
+Make sure to run \\[drepl-usql-build] after setting this option."
+ :type '(repeat symbol))
+
(defun drepl-usql-build ()
"Build the `drepl-usql' executable."
(interactive)
(let ((default-directory drepl-usql--directory)
(gocmd (or (bound-and-true-p go-command) "go")))
- (compile (format "%s build -v drepl-usql.go"
- (shell-quote-argument gocmd)))))
+ (with-temp-file "drivers.go"
+ (insert "package main\n\nimport (\n")
+ (dolist (s drepl-usql-drivers)
+ (insert (format "\t_ \"github.com/xo/usql/drivers/%s\"\n" s)))
+ (insert ")\n"))
+ (compile (format "%s build -v" (shell-quote-argument gocmd)))))
;;;###autoload (autoload 'drepl-usql "drepl-usql" nil t)
(drepl--define drepl-usql :display-name "usql")
@@ -65,8 +78,10 @@
(list prog (read-from-minibuffer "Connect to database: "
nil nil nil
'drepl-usql--connection-history))
- (lwarn 'drepl-usql :error
- "`%s' not found, built it with %s"
+ (lwarn 'drepl-usql :error "\
+`%s' not found.
+Use %s to build it.
+Note that this requires a Go compiler."
drepl-usql-program
(propertize "M-x drepl-usql-build" 'face 'help-key-binding))
(user-error "%s not found" drepl-usql-program)))
diff --git a/drepl-usql/drepl-usql.go b/drepl-usql/drepl-usql.go
index 6eb2723900..c92eddc707 100644
--- a/drepl-usql/drepl-usql.go
+++ b/drepl-usql/drepl-usql.go
@@ -18,15 +18,6 @@ import (
"github.com/xo/usql/handler"
"github.com/xo/usql/rline"
"github.com/xo/usql/text"
-
- // TODO: Make selected drivers customizable
- _ "github.com/xo/usql/drivers/clickhouse"
- _ "github.com/xo/usql/drivers/csvq"
- _ "github.com/xo/usql/drivers/mysql"
- _ "github.com/xo/usql/drivers/oracle"
- _ "github.com/xo/usql/drivers/postgres"
- _ "github.com/xo/usql/drivers/sqlite3"
- _ "github.com/xo/usql/drivers/sqlserver"
)
// Implements usql's rline.IO interface
diff --git a/drepl-usql/drivers.go b/drepl-usql/drivers.go
new file mode 100644
index 0000000000..82bf67e7b8
--- /dev/null
+++ b/drepl-usql/drivers.go
@@ -0,0 +1,11 @@
+package main
+
+import (
+ _ "github.com/xo/usql/drivers/clickhouse"
+ _ "github.com/xo/usql/drivers/csvq"
+ _ "github.com/xo/usql/drivers/mysql"
+ _ "github.com/xo/usql/drivers/oracle"
+ _ "github.com/xo/usql/drivers/postgres"
+ _ "github.com/xo/usql/drivers/sqlite3"
+ _ "github.com/xo/usql/drivers/sqlserver"
+)
diff --git a/drepl-usql/go.mod b/drepl-usql/go.mod
index 620c4a460b..30aff34b28 100644
--- a/drepl-usql/go.mod
+++ b/drepl-usql/go.mod
@@ -19,25 +19,31 @@ require (
github.com/alecthomas/kingpin/v2 v2.4.0 // indirect
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 //
indirect
github.com/andybalholm/brotli v1.1.0 // indirect
+ github.com/apache/arrow/go/v14 v14.0.2 // indirect
github.com/chzyer/test v1.0.0 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
+ github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 //
indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
+ github.com/google/flatbuffers/go v0.0.0-20230110200425-62e4d2e5b215 //
indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 //
indirect
github.com/kenshaw/rasterm v0.1.10 // indirect
github.com/klauspost/compress v1.17.7 // indirect
+ github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lib/pq v1.10.9 // indirect
+ github.com/marcboeker/go-duckdb v1.6.2 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-sixel v0.0.5 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/microsoft/go-mssqldb v1.7.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
+ github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mithrandie/csvq v1.18.1 // indirect
github.com/mithrandie/csvq-driver v1.7.0 // indirect
github.com/mithrandie/go-file/v2 v2.1.0 // indirect
@@ -57,12 +63,16 @@ require (
github.com/xo/dburl v0.22.0 // indirect
github.com/xo/tblfmt v0.12.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
+ github.com/zeebo/xxh3 v1.0.2 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
+ golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
+ golang.org/x/tools v0.19.0 // indirect
+ golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/drepl-usql/go.sum b/drepl-usql/go.sum
index 34b753e11c..152434e9df 100644
--- a/drepl-usql/go.sum
+++ b/drepl-usql/go.sum
@@ -564,6 +564,8 @@ github.com/yookoala/realpath v1.0.0/go.mod
h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Y
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod
h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.27/go.mod
h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod
h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
+github.com/zeebo/assert v1.3.0/go.mod
h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod
h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
github.com/ziutek/mymysql v1.5.4
h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
@@ -623,6 +625,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod
h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod
h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod
h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -648,6 +651,8 @@ golang.org/x/xerrors
v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028
h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod
h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
+gonum.org/v1/gonum v0.12.0 h1:xKuo6hzt+gMav00meVPUlXwSdoEJP46BR+wdxQEFK2o=
+gonum.org/v1/gonum v0.12.0/go.mod
h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY=
google.golang.org/api v0.172.0 h1:/1OcMZGPmW1rX2LCu2CmGUD1KXK1+pfzxotxyRUCCdk=
google.golang.org/api v0.172.0/go.mod
h1:+fJZq6QXWfa9pXhnIzsjx4yI22d4aI9ZpLb58gvXjis=
google.golang.org/appengine v1.6.8
h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=