Class: Bricolage::StreamingLoad::TaskHandlerOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/streamingload/taskhandler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ TaskHandlerOptions

Returns a new instance of TaskHandlerOptions.



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/bricolage/streamingload/taskhandler.rb', line 181

def initialize(argv)
  @argv = argv
  @environment = Context::DEFAULT_ENV
  @daemon = false
  @log_file_path = nil
  @pid_file_path = nil
  @working_dir = Dir.getwd
  @task_id = nil
  @force = false
  @noop = false
  @rest_arguments = nil

  @opts = opts = OptionParser.new("Usage: #{$0} CONFIG_PATH")
  opts.on('-e', '--environment=NAME', "Sets execution environment [default: #{@environment}]") {|env|
    @environment = env
  }
  opts.on('--daemon', 'Becomes daemon in server mode.') {
    @daemon = true
  }
  opts.on('--log-file=PATH', 'Log file path') {|path|
    @log_file_path = path
  }
  opts.on('--pid-file=PATH', 'Creates PID file.') {|path|
    @pid_file_path = path
  }
  opts.on('--working-dir=PATH', "Loader working directory. [default: #{@working_dir}]") {|path|
    @working_dir = path
  }
  opts.on('--task-id=ID', 'Execute oneshot load task (implicitly disables daemon mode).') {|task_id|
    @task_id = task_id
  }
  opts.on('--force', 'Disables loaded check.') {|path|
    @force = true
  }
  opts.on('--noop', 'Does not execute tasks.') {
    @noop = true
  }
  opts.on('--help', 'Prints this message and quit.') {
    puts opts.help
    exit 0
  }
  opts.on('--version', 'Prints version and quit.') {
    puts "#{File.basename($0)} version #{VERSION}"
    exit 0
  }
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



241
242
243
# File 'lib/bricolage/streamingload/taskhandler.rb', line 241

def environment
  @environment
end

#log_file_pathObject (readonly)

Returns the value of attribute log_file_path.



247
248
249
# File 'lib/bricolage/streamingload/taskhandler.rb', line 247

def log_file_path
  @log_file_path
end

#pid_file_pathObject (readonly)

Returns the value of attribute pid_file_path.



248
249
250
# File 'lib/bricolage/streamingload/taskhandler.rb', line 248

def pid_file_path
  @pid_file_path
end

#rest_argumentsObject (readonly)

Returns the value of attribute rest_arguments.



239
240
241
# File 'lib/bricolage/streamingload/taskhandler.rb', line 239

def rest_arguments
  @rest_arguments
end

#task_idObject (readonly)

Returns the value of attribute task_id.



251
252
253
# File 'lib/bricolage/streamingload/taskhandler.rb', line 251

def task_id
  @task_id
end

#working_dirObject (readonly)

Returns the value of attribute working_dir.



249
250
251
# File 'lib/bricolage/streamingload/taskhandler.rb', line 249

def working_dir
  @working_dir
end

Instance Method Details

#daemon?Boolean

Returns:

  • (Boolean)


243
244
245
# File 'lib/bricolage/streamingload/taskhandler.rb', line 243

def daemon?
  @daemon
end

#force?Boolean

Returns:

  • (Boolean)


253
254
255
# File 'lib/bricolage/streamingload/taskhandler.rb', line 253

def force?
  @force
end

#noop?Boolean

Returns:

  • (Boolean)


257
258
259
# File 'lib/bricolage/streamingload/taskhandler.rb', line 257

def noop?
  @noop
end

#parseObject



232
233
234
235
236
237
# File 'lib/bricolage/streamingload/taskhandler.rb', line 232

def parse
  @opts.parse!(@argv)
  @rest_arguments = @argv.dup
rescue OptionParser::ParseError => err
  raise OptionError, err.message
end

#usageObject



228
229
230
# File 'lib/bricolage/streamingload/taskhandler.rb', line 228

def usage
  @opts.help
end