embulk 0.8.27-java → 0.8.28-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -1
- data/appveyor.yml +4 -4
- data/bin/embulk +33 -9
- data/build.gradle +17 -4
- data/embulk-cli/build.gradle +1 -0
- data/embulk-cli/src/main/bat/{selfrun.bat → selfrun.bat.template} +1 -2
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java +54 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkBundle.java +44 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkCommandLine.java +256 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkCommandLineException.java +25 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkGlobalJRubyScriptingContainer.java +195 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkMigrate.java +9 -5
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkRun.java +769 -0
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkSelfUpdate.java +1 -14
- data/embulk-cli/src/main/java/org/embulk/cli/EmbulkSubcommand.java +47 -0
- data/embulk-cli/src/main/java/org/embulk/cli/Main.java +12 -21
- data/embulk-cli/src/main/java/org/embulk/cli/parse/AbstractHelpLineDefinition.java +15 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/CliHelpFormatterWithHelpMessages.java +141 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/CliOptionsWithHelpMessages.java +45 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/EmbulkCommandLineHelpRequired.java +10 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/EmbulkCommandLineParseException.java +25 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/EmbulkCommandLineParser.java +183 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/HelpMessageAsCliOption.java +36 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/HelpMessageLineDefinition.java +20 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/OptionBehavior.java +39 -0
- data/embulk-cli/src/main/java/org/embulk/cli/parse/OptionDefinition.java +120 -0
- data/embulk-cli/src/main/sh/{selfrun.sh → selfrun.sh.template} +1 -1
- data/embulk-cli/src/test/java/org/embulk/cli/SelfrunTest.java +7 -3
- data/embulk-core/src/main/java/org/embulk/EmbulkRunner.java +526 -0
- data/embulk-core/src/main/java/org/embulk/EmbulkSetup.java +70 -0
- data/embulk-core/src/main/java/org/embulk/plugin/PluginClassLoader.java +3 -3
- data/embulk-docs/src/release.rst +1 -0
- data/embulk-docs/src/release/release-0.8.28.rst +14 -0
- data/lib/embulk.rb +21 -17
- data/lib/embulk/runner.rb +35 -166
- data/lib/embulk/version.rb +1 -1
- metadata +29 -11
- data/lib/embulk/command/embulk_bundle.rb +0 -47
- data/lib/embulk/command/embulk_main.rb +0 -2
- data/lib/embulk/command/embulk_run.rb +0 -418
@@ -1,47 +0,0 @@
|
|
1
|
-
bundle_path = ENV['EMBULK_BUNDLE_PATH'].to_s
|
2
|
-
bundle_path = nil if bundle_path.empty?
|
3
|
-
|
4
|
-
# Search for -b or --bundle, and remove it.
|
5
|
-
bundle_option_index = ARGV.find_index {|arg| arg == '-b' || arg == '--bundle' }
|
6
|
-
if bundle_option_index
|
7
|
-
ARGV.slice!(bundle_option_index, 2)[1]
|
8
|
-
end
|
9
|
-
|
10
|
-
if bundle_path
|
11
|
-
# In the selfrun script:
|
12
|
-
# ENV['EMBULK_BUNDLE_PATH']: set through '-b' | '--bundle', or inherit from the runtime environment
|
13
|
-
# ENV['BUNDLE_GEMFILE']: set for "ENV['EMBULK_BUNDLE_PATH']/Gemfile"
|
14
|
-
# ENV['GEM_HOME']: unset
|
15
|
-
# ENV['GEM_PATH']: unset
|
16
|
-
|
17
|
-
# bundler is included in embulk-core.jar
|
18
|
-
Gem.clear_paths
|
19
|
-
require 'bundler'
|
20
|
-
|
21
|
-
Bundler.load.setup_environment
|
22
|
-
require 'bundler/setup'
|
23
|
-
# since here, `require` may load files of different (newer) embulk versions
|
24
|
-
# especially following 'embulk/command/embulk_main'.
|
25
|
-
|
26
|
-
# add bundle directory path to load local plugins at ./embulk
|
27
|
-
$LOAD_PATH << File.expand_path(bundle_path)
|
28
|
-
|
29
|
-
begin
|
30
|
-
require 'embulk/command/embulk_main'
|
31
|
-
rescue LoadError
|
32
|
-
$LOAD_PATH << File.expand_path('../../', File.dirname(__FILE__))
|
33
|
-
require 'embulk/command/embulk_main'
|
34
|
-
end
|
35
|
-
|
36
|
-
else
|
37
|
-
# In the selfrun script:
|
38
|
-
# ENV['EMBULK_BUNDLE_PATH']: unset
|
39
|
-
# ENV['BUNDLE_GEMFILE']: unset
|
40
|
-
# ENV['GEM_HOME']: set for "~/.embulk/jruby/${ruby-version}"
|
41
|
-
# ENV['GEM_PATH']: set for ""
|
42
|
-
|
43
|
-
Gem.clear_paths # force rubygems to reload GEM_HOME
|
44
|
-
|
45
|
-
$LOAD_PATH << File.expand_path('../../', File.dirname(__FILE__))
|
46
|
-
require 'embulk/command/embulk_main'
|
47
|
-
end
|
@@ -1,418 +0,0 @@
|
|
1
|
-
require 'embulk'
|
2
|
-
|
3
|
-
module Embulk
|
4
|
-
def self.run(argv)
|
5
|
-
# reset context class loader set by org.jruby.Main.main to nil. embulk manages
|
6
|
-
# multiple classloaders. default classloader should be Plugin.class.getClassloader().
|
7
|
-
java.lang.Thread.current_thread.set_context_class_loader(nil)
|
8
|
-
|
9
|
-
require 'embulk/version'
|
10
|
-
|
11
|
-
i = argv.find_index {|arg| arg !~ /^\-/ }
|
12
|
-
unless i
|
13
|
-
if argv.include?('--version')
|
14
|
-
puts "embulk #{Embulk::VERSION_INTERNAL}"
|
15
|
-
system_exit_success
|
16
|
-
end
|
17
|
-
usage nil
|
18
|
-
end
|
19
|
-
subcmd = argv.slice!(i).to_sym
|
20
|
-
|
21
|
-
require 'java'
|
22
|
-
require 'optparse'
|
23
|
-
op = OptionParser.new
|
24
|
-
op.version = Embulk::VERSION_INTERNAL
|
25
|
-
|
26
|
-
puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: Embulk v#{Embulk::VERSION_INTERNAL}"
|
27
|
-
|
28
|
-
plugin_paths = []
|
29
|
-
load_paths = []
|
30
|
-
classpaths = []
|
31
|
-
classpath_separator = java.io.File.pathSeparator
|
32
|
-
|
33
|
-
options = {
|
34
|
-
system_config: {}
|
35
|
-
}
|
36
|
-
|
37
|
-
java_embed_ops = lambda do
|
38
|
-
op.separator ""
|
39
|
-
op.separator " Other options:"
|
40
|
-
op.on('-l', '--log PATH', 'Output log messages to a file (default: -)') do |path|
|
41
|
-
options[:system_config][:log_path] = path
|
42
|
-
end
|
43
|
-
op.on('-l', '--log-level LEVEL', 'Log level (error, warn, info, debug or trace)') do |level|
|
44
|
-
options[:system_config][:log_level] = level
|
45
|
-
end
|
46
|
-
op.on('-X KEY=VALUE', 'Add a performance system config') do |kv|
|
47
|
-
k, v = kv.split('=', 2)
|
48
|
-
v ||= "true"
|
49
|
-
options[:system_config][k] = v
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
plugin_load_ops = lambda do
|
54
|
-
op.separator ""
|
55
|
-
op.separator " Plugin load options:"
|
56
|
-
op.on('-L', '--load PATH', 'Add a local plugin path') do |plugin_path|
|
57
|
-
plugin_paths << plugin_path
|
58
|
-
end
|
59
|
-
op.on('-I', '--load-path PATH', 'Add ruby script directory path ($LOAD_PATH)') do |load_path|
|
60
|
-
load_paths << load_path
|
61
|
-
end
|
62
|
-
op.on('-C', '--classpath PATH', "Add java classpath separated by #{classpath_separator} (CLASSPATH)") do |classpath|
|
63
|
-
classpaths.concat classpath.split(classpath_separator)
|
64
|
-
end
|
65
|
-
op.on('-b', '--bundle BUNDLE_DIR', 'Path to a Gemfile directory (create one using "embulk mkbundle" command)') do |path|
|
66
|
-
# only for help message. implemented at lib/embulk/command/embulk_bundle.rb
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
case subcmd
|
71
|
-
when :run
|
72
|
-
op.banner = "Usage: embulk run <config.yml>"
|
73
|
-
op.separator " Options:"
|
74
|
-
op.on('-r', '--resume-state PATH', 'Path to a file to write or read resume state') do |path|
|
75
|
-
options[:resume_state_path] = path
|
76
|
-
end
|
77
|
-
op.on('-o', '--output PATH', '(deprecated)') do |path|
|
78
|
-
STDERR.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: Run with -o option is deprecated. Please use -c option instead. For example,"
|
79
|
-
STDERR.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: "
|
80
|
-
STDERR.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: $ embulk run config.yml -c diff.yml"
|
81
|
-
STDERR.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: "
|
82
|
-
STDERR.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: This -c option stores only diff of the next configuration."
|
83
|
-
STDERR.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: The diff will be merged to the original config.yml file."
|
84
|
-
STDERR.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%3N %z")}: "
|
85
|
-
options[:next_config_output_path] = path
|
86
|
-
end
|
87
|
-
op.on('-c', '--config-diff PATH', 'Path to a file to read & write the next configuration diff') do |path|
|
88
|
-
options[:next_config_diff_path] = path
|
89
|
-
end
|
90
|
-
plugin_load_ops.call
|
91
|
-
java_embed_ops.call
|
92
|
-
args = 1..1
|
93
|
-
|
94
|
-
when :cleanup
|
95
|
-
op.banner = "Usage: embulk cleanup <config.yml>"
|
96
|
-
op.separator " Options:"
|
97
|
-
op.on('-r', '--resume-state PATH', 'Path to a file to cleanup resume state') do |path|
|
98
|
-
options[:resume_state_path] = path
|
99
|
-
end
|
100
|
-
plugin_load_ops.call
|
101
|
-
java_embed_ops.call
|
102
|
-
args = 1..1
|
103
|
-
|
104
|
-
when :preview
|
105
|
-
op.banner = "Usage: embulk preview <config.yml>"
|
106
|
-
op.separator " Options:"
|
107
|
-
op.on('-G', '--vertical', "Use vertical output format", TrueClass) do |b|
|
108
|
-
options[:format] = "vertical"
|
109
|
-
end
|
110
|
-
plugin_load_ops.call
|
111
|
-
java_embed_ops.call
|
112
|
-
args = 1..1
|
113
|
-
|
114
|
-
when :guess
|
115
|
-
op.banner = "Usage: embulk guess <partial-config.yml>"
|
116
|
-
op.separator " Options:"
|
117
|
-
op.on('-o', '--output PATH', 'Path to a file to write the guessed configuration') do |path|
|
118
|
-
options[:next_config_output_path] = path
|
119
|
-
end
|
120
|
-
op.on('-g', '--guess NAMES', "Comma-separated list of guess plugin names") do |names|
|
121
|
-
(options[:system_config][:guess_plugins] ||= []).concat names.split(",") # TODO
|
122
|
-
end
|
123
|
-
plugin_load_ops.call
|
124
|
-
java_embed_ops.call
|
125
|
-
args = 1..1
|
126
|
-
|
127
|
-
when :mkbundle
|
128
|
-
op.banner = "Usage: embulk mkbundle <directory> [--path PATH]"
|
129
|
-
op.separator " Options:"
|
130
|
-
op.on('--path PATH', 'Relative path from <directory> for the location to install gems to (e.g. --path shared/bundle).') do |path|
|
131
|
-
options[:bundle_path] = path
|
132
|
-
end
|
133
|
-
op.separator <<-EOF
|
134
|
-
|
135
|
-
"mkbundle" creates a new a plugin bundle directory. You can install
|
136
|
-
plugins (gems) to the directory instead of ~/.embulk.
|
137
|
-
|
138
|
-
See generated <directory>/Gemfile to install plugins to the directory.
|
139
|
-
Use -b, --bundle BUNDLE_DIR option to use it:
|
140
|
-
|
141
|
-
$ embulk mkbundle ./dir # create bundle directory
|
142
|
-
$ (cd dir && vi Gemfile && embulk bundle) # update plugin list
|
143
|
-
$ embulk guess -b ./dir ... # guess using bundled plugins
|
144
|
-
$ embulk run -b ./dir ... # run using bundled plugins
|
145
|
-
|
146
|
-
EOF
|
147
|
-
args = 1..1
|
148
|
-
|
149
|
-
when :bundle
|
150
|
-
if argv[0] == 'new'
|
151
|
-
usage nil if argv.length != 2
|
152
|
-
new_bundle(argv[1], nil)
|
153
|
-
STDERR.puts "'embulk bundle new' is deprecated. This will be removed in future release. Please use 'embulk mkbundle' instead."
|
154
|
-
else
|
155
|
-
run_bundler(argv)
|
156
|
-
end
|
157
|
-
system_exit_success
|
158
|
-
|
159
|
-
when :gem
|
160
|
-
require 'rubygems/gem_runner'
|
161
|
-
Gem::GemRunner.new.run argv
|
162
|
-
system_exit_success
|
163
|
-
|
164
|
-
when :new
|
165
|
-
op.banner = "Usage: embulk new <category> <name>" + %[
|
166
|
-
categories:
|
167
|
-
ruby-input Ruby record input plugin (like "mysql")
|
168
|
-
ruby-output Ruby record output plugin (like "mysql")
|
169
|
-
ruby-filter Ruby record filter plugin (like "add-hostname")
|
170
|
-
#ruby-file-input Ruby file input plugin (like "ftp") # not implemented yet [#21]
|
171
|
-
#ruby-file-output Ruby file output plugin (like "ftp") # not implemented yet [#22]
|
172
|
-
ruby-parser Ruby file parser plugin (like "csv")
|
173
|
-
ruby-formatter Ruby file formatter plugin (like "csv")
|
174
|
-
#ruby-decoder Ruby file decoder plugin (like "gzip") # not implemented yet [#31]
|
175
|
-
#ruby-encoder Ruby file encoder plugin (like "gzip") # not implemented yet [#32]
|
176
|
-
java-input Java record input plugin (like "mysql")
|
177
|
-
java-output Java record output plugin (like "mysql")
|
178
|
-
java-filter Java record filter plugin (like "add-hostname")
|
179
|
-
java-file-input Java file input plugin (like "ftp")
|
180
|
-
java-file-output Java file output plugin (like "ftp")
|
181
|
-
java-parser Java file parser plugin (like "csv")
|
182
|
-
java-formatter Java file formatter plugin (like "csv")
|
183
|
-
java-decoder Java file decoder plugin (like "gzip")
|
184
|
-
java-encoder Java file encoder plugin (like "gzip")
|
185
|
-
|
186
|
-
examples:
|
187
|
-
new ruby-output hbase
|
188
|
-
new ruby-filter int-to-string
|
189
|
-
]
|
190
|
-
args = 2..2
|
191
|
-
|
192
|
-
when :migrate
|
193
|
-
op.banner = "Usage: embulk migrate <directory>"
|
194
|
-
args = 1..1
|
195
|
-
|
196
|
-
when :selfupdate
|
197
|
-
op.on('-f', "Skip corruption check", TrueClass) do |b|
|
198
|
-
options[:force] = true
|
199
|
-
end
|
200
|
-
args = 0..1
|
201
|
-
|
202
|
-
when :example
|
203
|
-
args = 0..1
|
204
|
-
|
205
|
-
when :exec
|
206
|
-
exec(*argv)
|
207
|
-
exit 127
|
208
|
-
|
209
|
-
when :irb
|
210
|
-
require 'irb'
|
211
|
-
IRB.start
|
212
|
-
system_exit_success
|
213
|
-
|
214
|
-
else
|
215
|
-
usage "Unknown subcommand #{subcmd.to_s.dump}."
|
216
|
-
end
|
217
|
-
|
218
|
-
begin
|
219
|
-
op.parse!(argv)
|
220
|
-
unless args.include?(argv.length)
|
221
|
-
usage_op op, nil
|
222
|
-
end
|
223
|
-
rescue => e
|
224
|
-
usage_op op, e.to_s
|
225
|
-
end
|
226
|
-
|
227
|
-
case subcmd
|
228
|
-
when :example
|
229
|
-
(org.embulk.cli.EmbulkExample.new).createExample(ARGV[0] || "embulk-example")
|
230
|
-
|
231
|
-
when :new
|
232
|
-
(org.embulk.cli.EmbulkNew.new(ARGV[0], ARGV[1], Embulk::VERSION_INTERNAL)).newPlugin()
|
233
|
-
|
234
|
-
when :migrate
|
235
|
-
(org.embulk.cli.EmbulkMigrate.new).migratePlugin(ARGV[0], Embulk::VERSION_INTERNAL)
|
236
|
-
|
237
|
-
when :selfupdate
|
238
|
-
(org.embulk.cli.EmbulkSelfUpdate.new).updateSelf(Embulk::VERSION_INTERNAL,
|
239
|
-
ARGV[0],
|
240
|
-
__FILE__,
|
241
|
-
options[:force])
|
242
|
-
|
243
|
-
when :mkbundle
|
244
|
-
new_bundle(argv[0], options[:bundle_path])
|
245
|
-
|
246
|
-
else
|
247
|
-
require 'json'
|
248
|
-
|
249
|
-
# Gem::StubSpecification is an internal API that seems chainging often.
|
250
|
-
# Gem::Specification.add_spec is deprecated also. Therefore, here makes
|
251
|
-
# -L <path> option alias of -I <path>/lib by assuming that *.gemspec file
|
252
|
-
# always has require_paths = ["lib"].
|
253
|
-
load_paths = load_paths + plugin_paths.map {|path| File.join(path, "lib") }
|
254
|
-
|
255
|
-
setup_load_paths(load_paths)
|
256
|
-
setup_classpaths(classpaths)
|
257
|
-
|
258
|
-
# call setup after setup_classpaths to allow users to overwrite
|
259
|
-
# embulk classes
|
260
|
-
Embulk.setup(options.delete(:system_config))
|
261
|
-
|
262
|
-
begin
|
263
|
-
case subcmd
|
264
|
-
when :guess
|
265
|
-
Embulk::Runner.guess(argv[0], options)
|
266
|
-
when :preview
|
267
|
-
Embulk::Runner.preview(argv[0], options)
|
268
|
-
when :run
|
269
|
-
Embulk::Runner.run(argv[0], options)
|
270
|
-
end
|
271
|
-
rescue => ex
|
272
|
-
print_exception(ex)
|
273
|
-
puts ""
|
274
|
-
puts "Error: #{ex}"
|
275
|
-
raise SystemExit.new(1, ex.to_s)
|
276
|
-
end
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
def self.default_gem_home
|
281
|
-
if RUBY_PLATFORM =~ /java/i
|
282
|
-
user_home = java.lang.System.properties["user.home"]
|
283
|
-
end
|
284
|
-
user_home ||= ENV['HOME']
|
285
|
-
unless user_home
|
286
|
-
raise "HOME environment variable is not set."
|
287
|
-
end
|
288
|
-
File.expand_path File.join(user_home, '.embulk', Gem.ruby_engine, RbConfig::CONFIG['ruby_version'])
|
289
|
-
end
|
290
|
-
|
291
|
-
private
|
292
|
-
|
293
|
-
def self.setup_load_paths(load_paths)
|
294
|
-
# first $LOAD_PATH has highet priority. later load_paths should have highest priority.
|
295
|
-
load_paths.each do |load_path|
|
296
|
-
# ruby script directory (use unshift to make it highest priority)
|
297
|
-
$LOAD_PATH.unshift File.expand_path(load_path)
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
def self.setup_classpaths(classpaths)
|
302
|
-
classpaths.each do |classpath|
|
303
|
-
$CLASSPATH << classpath # $CLASSPATH object doesn't have concat method
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
def self.new_bundle(path, bundle_path)
|
308
|
-
require 'fileutils'
|
309
|
-
require 'rubygems/gem_runner'
|
310
|
-
|
311
|
-
if File.exists?(path)
|
312
|
-
error = "'#{path}' already exists."
|
313
|
-
STDERR.puts error
|
314
|
-
raise SystemExit.new(1, error)
|
315
|
-
end
|
316
|
-
|
317
|
-
puts "Initializing #{path}..."
|
318
|
-
FileUtils.mkdir_p path
|
319
|
-
begin
|
320
|
-
success = false
|
321
|
-
|
322
|
-
# copy embulk/data/bundle/ contents
|
323
|
-
require 'embulk/data/package_data'
|
324
|
-
pkg = PackageData.new("bundle", path)
|
325
|
-
%w[Gemfile .ruby-version .bundle/config embulk/input/example.rb embulk/output/example.rb embulk/filter/example.rb].each do |file|
|
326
|
-
pkg.cp(file, file)
|
327
|
-
end
|
328
|
-
|
329
|
-
# run the first bundle-install
|
330
|
-
Dir.chdir(path) do
|
331
|
-
run_bundler(['install', '--path', bundle_path || "."])
|
332
|
-
end
|
333
|
-
|
334
|
-
success = true
|
335
|
-
rescue Gem::SystemExitException => e
|
336
|
-
raise e if e.exit_code != 0
|
337
|
-
success = true
|
338
|
-
ensure
|
339
|
-
FileUtils.rm_rf path unless success
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
def self.run_bundler(argv)
|
344
|
-
require 'bundler' # bundler is included in embulk-core.jar
|
345
|
-
|
346
|
-
# this hack is necessary to make --help working
|
347
|
-
Bundler.define_singleton_method(:which_orig, Bundler.method(:which))
|
348
|
-
Bundler.define_singleton_method(:which) do |executable|
|
349
|
-
if executable == "man"
|
350
|
-
false
|
351
|
-
else
|
352
|
-
which_orig(executable)
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
require 'bundler/friendly_errors'
|
357
|
-
require 'bundler/cli'
|
358
|
-
Bundler.with_friendly_errors do
|
359
|
-
Bundler::CLI.start(argv, debug: true)
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
def self.usage(message)
|
364
|
-
STDERR.puts "Embulk v#{Embulk::VERSION_INTERNAL}"
|
365
|
-
STDERR.puts "Usage: embulk [-vm-options] <command> [--options]"
|
366
|
-
STDERR.puts "Commands:"
|
367
|
-
STDERR.puts " mkbundle <directory> # create a new plugin bundle environment."
|
368
|
-
STDERR.puts " bundle [directory] # update a plugin bundle environment."
|
369
|
-
STDERR.puts " run <config.yml> # run a bulk load transaction."
|
370
|
-
STDERR.puts " cleanup <config.yml> # cleanup resume state."
|
371
|
-
STDERR.puts " preview <config.yml> # dry-run the bulk load without output and show preview."
|
372
|
-
STDERR.puts " guess <partial-config.yml> -o <output.yml> # guess missing parameters to create a complete configuration file."
|
373
|
-
STDERR.puts " gem <install | list | help> # install a plugin or show installed plugins."
|
374
|
-
STDERR.puts " # plugin path is #{ENV['GEM_HOME']}"
|
375
|
-
STDERR.puts " new <category> <name> # generates new plugin template"
|
376
|
-
STDERR.puts " migrate <path> # modify plugin code to use the latest Embulk plugin API"
|
377
|
-
STDERR.puts " example [path] # creates an example config file and csv file to try embulk."
|
378
|
-
STDERR.puts " selfupdate [version] # upgrades embulk to the latest released version or to the specified version."
|
379
|
-
STDERR.puts ""
|
380
|
-
STDERR.puts "VM options:"
|
381
|
-
STDERR.puts " -J-O Disable JVM optimizations to speed up startup time (enabled by default if command is 'run')"
|
382
|
-
STDERR.puts " -J+O Enable JVM optimizations to speed up throughput"
|
383
|
-
STDERR.puts " -J... Set JVM options (use -J-help to see available options)"
|
384
|
-
STDERR.puts " -R... Set JRuby options (use -R--help to see available options)"
|
385
|
-
STDERR.puts ""
|
386
|
-
if message
|
387
|
-
system_exit "error: #{message}"
|
388
|
-
else
|
389
|
-
system_exit "Use \`<command> --help\` to see description of the commands."
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
def self.usage_op(op, message)
|
394
|
-
STDERR.puts op.help
|
395
|
-
STDERR.puts
|
396
|
-
system_exit message
|
397
|
-
end
|
398
|
-
|
399
|
-
def self.print_exception(ex)
|
400
|
-
if ex.respond_to?(:to_java) && ex.is_a?(java.lang.Throwable)
|
401
|
-
ex.to_java.printStackTrace(java.lang.System.out)
|
402
|
-
else
|
403
|
-
puts "#{ex.to_s}"
|
404
|
-
ex.backtrace.each do |bt|
|
405
|
-
puts " #{bt}"
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
def self.system_exit(message=nil)
|
411
|
-
STDERR.puts message if message
|
412
|
-
raise SystemExit.new(1, message)
|
413
|
-
end
|
414
|
-
|
415
|
-
def self.system_exit_success
|
416
|
-
raise SystemExit.new(0)
|
417
|
-
end
|
418
|
-
end
|