slyce 0.9.5 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/slyce +5 -1
- data/bin/slyce3 +17 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 380c2147a52bd30761850468c1a06b6f041523d66ed513912a0756a51d80d7d5
|
4
|
+
data.tar.gz: 1f306e010169260bc76a5bfb7200d2c9c0ca87ca76fc27b143b9e61e6310ef14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33369805c3929785f1709b567484d35ceaeb2d0502c5db8db8c1a26ea50e31f43dd39d48f6ac605e4cf294e8ea727fa3f9c5977091c3c48e25c68a4080c6e444
|
7
|
+
data.tar.gz: ef9ca1f35c4f6c172f231b9609fc72968e393ffbf45005973a4918e293af59ca53d82dbd8d7788f829a783213c70a020b88640939c64fbc1db5395659272507e
|
data/bin/slyce
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
VERSION="0.9.
|
3
|
+
VERSION="0.9.7"
|
4
4
|
|
5
5
|
STDOUT.sync = true
|
6
6
|
|
@@ -73,6 +73,10 @@ if opts[:columns]
|
|
73
73
|
exit
|
74
74
|
end
|
75
75
|
|
76
|
+
if want.empty?
|
77
|
+
abort "no columns are selected"
|
78
|
+
end
|
79
|
+
|
76
80
|
want.each do |name|
|
77
81
|
sort = abcd ? "" : "cnt desc,"
|
78
82
|
stmt = show ? "limit #{show}" : ""
|
data/bin/slyce3
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# NOTE: Requires the 'regexp' sqlite3 extension from https://github.com/nalgeon/sqlean
|
4
|
+
#
|
5
|
+
# Downloads from https://github.com/nalgeon/sqlean/releases/latest
|
6
|
+
#
|
7
|
+
# For example, on Apple Silicon with macOS with an M1 you can use:
|
8
|
+
#
|
9
|
+
# wget https://github.com/nalgeon/sqlean/releases/download/0.19.3/sqlean-macos-arm64.zip
|
10
|
+
# unzip sqlean-macos-arm64.zip regexp.dylib
|
4
11
|
|
5
|
-
VERSION="0.9.
|
12
|
+
VERSION="0.9.7"
|
6
13
|
|
7
14
|
STDOUT.sync = true
|
8
15
|
|
@@ -27,17 +34,19 @@ OptionParser.new.instance_eval do
|
|
27
34
|
on "-x", "--extract <col1,col2,...>", "Comma separated list of columns to extract"
|
28
35
|
|
29
36
|
self
|
30
|
-
end.parse!(into: opts={
|
37
|
+
end.parse!(into: opts={}) rescue abort($!.message)
|
31
38
|
|
32
39
|
abcd = opts[:alpha]
|
33
40
|
filt = opts[:where] and filt = "where\n #{filt}"
|
34
|
-
regx = opts[:regexp]
|
41
|
+
regx = opts[:regexp] || Dir["{,sqlean}/regexp.{dll,dylib,so}"].first
|
35
42
|
show = opts[:show]
|
36
43
|
want = opts[:extract].to_s.downcase.split(",")
|
37
44
|
|
38
45
|
dbas ||= ARGV.shift or abort "no database given"
|
39
46
|
tabl ||= ARGV.shift or abort "no table given"
|
40
47
|
|
48
|
+
regx && File.exist?(regx) or abort "no regexp extension found#{regx ? " at '#{regx}'" : ''}"
|
49
|
+
|
41
50
|
# ==[ Helpers ]==
|
42
51
|
|
43
52
|
class Extralite::Database
|
@@ -68,7 +77,7 @@ end
|
|
68
77
|
# ==[ Let 'er rip! ]==
|
69
78
|
|
70
79
|
conn = Extralite::Database.new(dbas)
|
71
|
-
resu = conn.load_extension(regx)
|
80
|
+
resu = conn.load_extension(regx) rescue abort("unable to load regexp extension '#{regx}'")
|
72
81
|
cols = conn.columns("select * from `#{tabl}` limit 0").map(&:to_s)
|
73
82
|
want = want.empty? ? cols : want & cols
|
74
83
|
|
@@ -77,6 +86,10 @@ if opts[:columns]
|
|
77
86
|
exit
|
78
87
|
end
|
79
88
|
|
89
|
+
if want.empty?
|
90
|
+
abort "no columns are selected"
|
91
|
+
end
|
92
|
+
|
80
93
|
want.each do |name|
|
81
94
|
sort = abcd ? "" : "cnt desc,"
|
82
95
|
stmt = show ? "limit #{show}" : ""
|