lib/chronicle/etl/cli/jobs.rb in chronicle-etl-0.4.0 vs lib/chronicle/etl/cli/jobs.rb in chronicle-etl-0.4.1
- old
+ new
@@ -4,32 +4,33 @@
module ETL
module CLI
# CLI commands for working with ETL jobs
class Jobs < SubcommandBase
default_task "start"
- namespace :jobs
+ namespace :jobs
class_option :name, aliases: '-j', desc: 'Job configuration name'
- class_option :extractor, aliases: '-e', desc: "Extractor class. Default: stdin", banner: 'extractor-name'
+ class_option :extractor, aliases: '-e', desc: "Extractor class. Default: stdin", banner: 'NAME'
class_option :'extractor-opts', desc: 'Extractor options', type: :hash, default: {}
- class_option :transformer, aliases: '-t', desc: 'Transformer class. Default: null', banner: 'transformer-name'
+ class_option :transformer, aliases: '-t', desc: 'Transformer class. Default: null', banner: 'NAME'
class_option :'transformer-opts', desc: 'Transformer options', type: :hash, default: {}
- class_option :loader, aliases: '-l', desc: 'Loader class. Default: stdout', banner: 'loader-name'
+ class_option :loader, aliases: '-l', desc: 'Loader class. Default: table', banner: 'NAME'
class_option :'loader-opts', desc: 'Loader options', type: :hash, default: {}
# This is an array to deal with shell globbing
class_option :input, aliases: '-i', desc: 'Input filename or directory', default: [], type: 'array', banner: 'FILENAME'
- class_option :since, desc: "Load records SINCE this date. Overrides job's `load_since` configuration option in extractor's options", banner: 'DATE'
+ class_option :since, desc: "Load records SINCE this date", banner: 'DATE'
class_option :until, desc: "Load records UNTIL this date", banner: 'DATE'
class_option :limit, desc: "Only extract the first LIMIT records", banner: 'N'
class_option :output, aliases: '-o', desc: 'Output filename', type: 'string'
class_option :fields, desc: 'Output only these fields', type: 'array', banner: 'field1 field2 ...'
class_option :log_level, desc: 'Log level (debug, info, warn, error, fatal)', default: 'info'
class_option :verbose, aliases: '-v', desc: 'Set log level to verbose', type: :boolean
+ class_option :silent, desc: 'Silence all output', type: :boolean
# Thor doesn't like `run` as a command name
map run: :start
desc "run", "Start a job"
option :log_level, desc: 'Log level (debug, info, warn, error, fatal)', default: 'info'
@@ -91,11 +92,13 @@
end
private
def setup_log_level
- if options[:verbose]
+ if options[:silent]
+ Chronicle::ETL::Logger.log_level = Chronicle::ETL::Logger::SILENT
+ elsif options[:verbose]
Chronicle::ETL::Logger.log_level = Chronicle::ETL::Logger::DEBUG
elsif options[:log_level]
level = Chronicle::ETL::Logger.const_get(options[:log_level].upcase)
Chronicle::ETL::Logger.log_level = level
end
@@ -114,10 +117,10 @@
end
# Takes flag options and turns them into a runner config
def process_flag_options options
extractor_options = options[:'extractor-opts'].merge({
- filename: (options[:input] if options[:input].any?),
+ input: (options[:input] if options[:input].any?),
since: options[:since],
until: options[:until],
limit: options[:limit],
}.compact)