Class: Bricolage::JobNetRunner::Options
- Inherits:
-
CommonApplicationOptions
- Object
- CommonApplicationOptions
- Bricolage::JobNetRunner::Options
- Defined in:
- lib/bricolage/jobnetrunner.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#jobnet_files ⇒ Object
readonly
Returns the value of attribute jobnet_files.
-
#option_variables ⇒ Object
readonly
Returns the value of attribute option_variables.
Attributes inherited from CommonApplicationOptions
Instance Method Summary collapse
- #check_only? ⇒ Boolean
- #clear_queue? ⇒ Boolean
- #db_name ⇒ Object
- #define_options(parser) ⇒ Object
- #dump_options? ⇒ Boolean
- #enable_queue? ⇒ Boolean
- #executor_type ⇒ Object
- #help ⇒ Object
-
#initialize(app) ⇒ Options
constructor
A new instance of Options.
- #list_jobs? ⇒ Boolean
- #local_state_dir ⇒ Object
- #on(*args, &block) ⇒ Object
- #option_pairs ⇒ Object
- #parse!(argv) ⇒ Object
- #queue_path ⇒ Object
Methods inherited from CommonApplicationOptions
#common_options, #log_path_format, #log_s3_ds, #log_s3_key_format, #merge_saved_options, #s3_log_spec
Constructor Details
#initialize(app) ⇒ Options
Returns a new instance of Options.
221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/bricolage/jobnetrunner.rb', line 221 def initialize(app) @app = app @environment = nil @option_variables = Variables.new @jobnet_files = nil @dump_options = false @check_only = false @list_jobs = false @clear_queue = false end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
335 336 337 |
# File 'lib/bricolage/jobnetrunner.rb', line 335 def environment @environment end |
#jobnet_files ⇒ Object (readonly)
Returns the value of attribute jobnet_files.
337 338 339 |
# File 'lib/bricolage/jobnetrunner.rb', line 337 def jobnet_files @jobnet_files end |
#option_variables ⇒ Object (readonly)
Returns the value of attribute option_variables.
339 340 341 |
# File 'lib/bricolage/jobnetrunner.rb', line 339 def option_variables @option_variables end |
Instance Method Details
#check_only? ⇒ Boolean
345 346 347 |
# File 'lib/bricolage/jobnetrunner.rb', line 345 def check_only? @check_only end |
#clear_queue? ⇒ Boolean
392 393 394 |
# File 'lib/bricolage/jobnetrunner.rb', line 392 def clear_queue? @clear_queue end |
#db_name ⇒ Object
374 375 376 377 378 379 380 381 |
# File 'lib/bricolage/jobnetrunner.rb', line 374 def db_name opt = @opts['db-name'] if opt.value opt.value else nil end end |
#define_options(parser) ⇒ Object
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/bricolage/jobnetrunner.rb', line 265 def (parser) parser. = <<-EndBanner Synopsis: #{@app.program_name} [options] JOB_NET_FILE Options: EndBanner parser.on('-e', '--environment=NAME', "Sets execution environment. [default: #{Context::DEFAULT_ENV}]") {|env| @environment = env } parser.on('--local-state-dir=PATH', 'Stores local state in this path.') {|path| @opts_cmdline['local-state-dir'] = OptionValue.new('--local-state-dir option', path) } parser.on('-Q', '--enable-queue', 'Enables job queue.') { @opts_cmdline['enable-queue'] = OptionValue.new('--enable-queue option', true) } parser.on('--disable-queue', 'Disables job queue.') { @opts_cmdline['enable-queue'] = OptionValue.new('--disable-queue option', false) } parser.on('--clear-queue', 'Clears job queue and quit.') { @clear_queue = true } parser.on('--queue-path=PATH', 'Enables job queue with this path.') {|path| @opts_cmdline['queue-path'] = OptionValue.new('--queue-path option', path) } parser.on('--db-name=DB_NAME', 'Enables job queue with this database.') {|db_name| @opts_cmdline['db-name'] = OptionValue.new('--db-name option', db_name) } parser.on('--ecs-executor', 'Set executor type as ECS ') { @opts_cmdline['ecs-executor'] = OptionValue.new('--ecs-executor option', true) } parser.on('-c', '--check-only', 'Checks job parameters and quit without executing.') { @check_only = true } parser.on('-l', '--list-jobs', 'Lists target jobs without executing.') { @list_jobs = true } parser.on('-v', '--variable=NAME=VALUE', 'Defines option variable.') {|name_value| name, value = name_value.split('=', 2) @option_variables[name] = value } parser.on('--dump-options', 'Shows option parsing result and quit.') { @dump_options = true } parser.on('--help', 'Shows this message and quit.') { @app.puts parser.help @app.exit 0 } parser.on('--version', 'Shows program version and quit.') { @app.puts "#{APPLICATION_NAME} version #{VERSION}" @app.exit 0 } end |
#dump_options? ⇒ Boolean
341 342 343 |
# File 'lib/bricolage/jobnetrunner.rb', line 341 def @dump_options end |
#enable_queue? ⇒ Boolean
360 361 362 363 |
# File 'lib/bricolage/jobnetrunner.rb', line 360 def enable_queue? opt = @opts['enable-queue'] opt.value end |
#executor_type ⇒ Object
383 384 385 386 387 388 389 390 |
# File 'lib/bricolage/jobnetrunner.rb', line 383 def executor_type opt = @opts['ecs-executor'] if opt.value 'ecs' else 'ec2' end end |
#help ⇒ Object
261 262 263 |
# File 'lib/bricolage/jobnetrunner.rb', line 261 def help @parser.help end |
#list_jobs? ⇒ Boolean
349 350 351 |
# File 'lib/bricolage/jobnetrunner.rb', line 349 def list_jobs? @list_jobs end |
#local_state_dir ⇒ Object
353 354 355 356 357 358 |
# File 'lib/bricolage/jobnetrunner.rb', line 353 def local_state_dir @local_state_dir ||= begin opt = @opts['local-state-dir'] Pathname(opt.value) end end |
#on(*args, &block) ⇒ Object
322 323 324 |
# File 'lib/bricolage/jobnetrunner.rb', line 322 def on(*args, &block) @parser.on(*args, &block) end |
#option_pairs ⇒ Object
396 397 398 399 400 |
# File 'lib/bricolage/jobnetrunner.rb', line 396 def option_pairs .merge({ 'environment' => OptionValue.new(nil, @environment) }) end |
#parse!(argv) ⇒ Object
326 327 328 329 330 331 332 333 |
# File 'lib/bricolage/jobnetrunner.rb', line 326 def parse!(argv) @parser.parse!(argv) raise OptionError, "missing jobnet file" if argv.empty? @jobnet_files = argv.map {|path| Pathname(path) } rescue OptionParser::ParseError => ex raise OptionError, ex. end |
#queue_path ⇒ Object
365 366 367 368 369 370 371 372 |
# File 'lib/bricolage/jobnetrunner.rb', line 365 def queue_path opt = @opts['queue-path'] if opt.value Pathname(opt.value) else nil end end |