ath 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ath/cli.rb +36 -29
- data/lib/ath/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42da3723a1c3f60623c4b20943452062c8789d93
|
4
|
+
data.tar.gz: 3205352665c60c5fc979bb1bde149c08f165c101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb69186162a3ab810177f11e10015dbd12e75ba954293526a2d6cfcaac9262e77f878df35a67ead57092bae922a45032a41f4a03df5ac4db057f27b325af2c51
|
7
|
+
data.tar.gz: 5b9318386d31b7a0437c44f3d4c49dcbb17e9d29be990aab4cb6bb84b70993d1ae79ade1f578363b6e5690bc1416fbeb195f2bd4fc38f228e3fd446010484b7d
|
data/lib/ath/cli.rb
CHANGED
@@ -60,7 +60,12 @@ class Ath::CLI
|
|
60
60
|
)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
begin
|
64
|
+
options[:output_location] = ERB.new(options[:output_location]).result
|
65
|
+
rescue => e
|
66
|
+
$stderr.puts("[ERROR] Eval output-location failed: #{e.message}")
|
67
|
+
exit 1
|
68
|
+
end
|
64
69
|
|
65
70
|
return [options, query, query_file]
|
66
71
|
end
|
@@ -68,37 +73,39 @@ class Ath::CLI
|
|
68
73
|
def main
|
69
74
|
options, query, query_file = parse_options
|
70
75
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
+
begin
|
77
|
+
shell = Ath::Shell.new(
|
78
|
+
output_location: options.delete(:output_location),
|
79
|
+
database: options.delete(:database),
|
80
|
+
pager: options.delete(:pager),
|
81
|
+
options: options)
|
76
82
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
83
|
+
if query_file
|
84
|
+
if query_file == '-'
|
85
|
+
query = $stdin.read
|
86
|
+
else
|
87
|
+
query = File.read(query_file)
|
88
|
+
end
|
82
89
|
end
|
83
|
-
end
|
84
90
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
91
|
+
if query
|
92
|
+
options[:progress] = false unless options.has_key?(:progress)
|
93
|
+
query.strip!
|
94
|
+
query << ';' if query !~ /[;&]\z/
|
95
|
+
shell.oneshot(query)
|
96
|
+
else
|
97
|
+
options[:progress] = true unless options.has_key?(:progress)
|
98
|
+
shell.start
|
99
|
+
end
|
100
|
+
rescue Interrupt
|
101
|
+
# nothing to do
|
102
|
+
rescue => e
|
103
|
+
if options[:debug]
|
104
|
+
raise e
|
105
|
+
else
|
106
|
+
$stderr.puts("[ERROR] #{[e.message, e.backtrace.first].join("\n\t")}")
|
107
|
+
exit 1
|
108
|
+
end
|
102
109
|
end
|
103
110
|
end
|
104
111
|
end
|
data/lib/ath/version.rb
CHANGED