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.
-
#global_variables ⇒ Object
readonly
Returns the value of attribute global_variables.
-
#jobnet_file ⇒ Object
readonly
Returns the value of attribute jobnet_file.
Attributes inherited from CommonApplicationOptions
Instance Method Summary collapse
- #check_only? ⇒ Boolean
- #define_options(parser) ⇒ Object
- #dump_options? ⇒ Boolean
- #enable_queue? ⇒ Boolean
- #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.
200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/bricolage/jobnetrunner.rb', line 200 def initialize(app) @app = app @environment = nil @global_variables = Variables.new @jobnet_files = nil = false @check_only = false @list_jobs = false end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
296 297 298 |
# File 'lib/bricolage/jobnetrunner.rb', line 296 def environment @environment end |
#global_variables ⇒ Object (readonly)
Returns the value of attribute global_variables.
299 300 301 |
# File 'lib/bricolage/jobnetrunner.rb', line 299 def global_variables @global_variables end |
#jobnet_file ⇒ Object (readonly)
Returns the value of attribute jobnet_file.
297 298 299 |
# File 'lib/bricolage/jobnetrunner.rb', line 297 def jobnet_file @jobnet_file end |
Instance Method Details
#check_only? ⇒ Boolean
305 306 307 |
# File 'lib/bricolage/jobnetrunner.rb', line 305 def check_only? @check_only end |
#define_options(parser) ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/bricolage/jobnetrunner.rb', line 238 def (parser) parser. = "Synopsis:\n \#{@app.program_name} [options] JOB_NET_FILE\nOptions:\n EndBanner\n parser.on('-e', '--environment=NAME', \"Sets execution environment. [default: \#{Context::DEFAULT_ENV}]\") {|env|\n @environment = env\n }\n\n define_common_options\n\n parser.on('--local-state-dir=PATH', 'Stores local state in this path.') {|path|\n @opts_cmdline['local-state-dir'] = OptionValue.new('--local-state-dir option', path)\n }\n parser.on('-Q', '--enable-queue', 'Enables job queue.') {\n @opts_cmdline['enable-queue'] = OptionValue.new('--enable-queue option', true)\n }\n parser.on('--queue-path=PATH', 'Enables job queue with this path.') {|path|\n @opts_cmdline['queue-path'] = OptionValue.new('--queue-path option', path)\n }\n parser.on('-c', '--check-only', 'Checks job parameters and quit without executing.') {\n @check_only = true\n }\n parser.on('-l', '--list-jobs', 'Lists target jobs without executing.') {\n @list_jobs = true\n }\n parser.on('-v', '--variable=NAME=VALUE', 'Defines global variable.') {|name_value|\n name, value = name_value.split('=', 2)\n @global_variables[name] = value\n }\n parser.on('--dump-options', 'Shows option parsing result and quit.') {\n @dump_options = true\n }\n parser.on('--help', 'Shows this message and quit.') {\n @app.puts parser.help\n @app.exit 0\n }\n parser.on('--version', 'Shows program version and quit.') {\n @app.puts \"\#{APPLICATION_NAME} version \#{VERSION}\"\n @app.exit 0\n }\nend\n" |
#dump_options? ⇒ Boolean
301 302 303 |
# File 'lib/bricolage/jobnetrunner.rb', line 301 def end |
#enable_queue? ⇒ Boolean
320 321 322 323 |
# File 'lib/bricolage/jobnetrunner.rb', line 320 def enable_queue? opt = @opts['enable-queue'] opt.value end |
#help ⇒ Object
234 235 236 |
# File 'lib/bricolage/jobnetrunner.rb', line 234 def help @parser.help end |
#list_jobs? ⇒ Boolean
309 310 311 |
# File 'lib/bricolage/jobnetrunner.rb', line 309 def list_jobs? @list_jobs end |
#local_state_dir ⇒ Object
313 314 315 316 317 318 |
# File 'lib/bricolage/jobnetrunner.rb', line 313 def local_state_dir @local_state_dir ||= begin opt = @opts['local-state-dir'] Pathname(opt.value) end end |
#on(*args, &block) ⇒ Object
282 283 284 |
# File 'lib/bricolage/jobnetrunner.rb', line 282 def on(*args, &block) @parser.on(*args, &block) end |
#option_pairs ⇒ Object
334 335 336 337 338 |
# File 'lib/bricolage/jobnetrunner.rb', line 334 def option_pairs .merge({ 'environment' => OptionValue.new(nil, @environment) }) end |
#parse!(argv) ⇒ Object
286 287 288 289 290 291 292 293 294 |
# File 'lib/bricolage/jobnetrunner.rb', line 286 def parse!(argv) @parser.parse!(argv) raise OptionError, "missing jobnet file" if argv.empty? raise OptionError, "too many jobnet file" if argv.size > 1 @jobnet_file = Pathname(argv.first) rescue OptionParser::ParseError => ex raise OptionError, ex. end |
#queue_path ⇒ Object
325 326 327 328 329 330 331 332 |
# File 'lib/bricolage/jobnetrunner.rb', line 325 def queue_path opt = @opts['queue-path'] if opt.value Pathname(opt.value) else nil end end |