MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / parse_main_args

Function parse_main_args

ruby/engine/openstudio_cli.rb:307–701  ·  view source on GitHub ↗

parse the main args, those that come before the sub command

(main_args)

Source from the content-addressed store, hash-verified

305
306# parse the main args, those that come before the sub command
307def parse_main_args(main_args)
308
309 # Unset RUBY ENVs if previously set (e.g. rvm sets these in shell)
310
311 ENV.delete('GEM_HOME') if ENV['GEM_HOME']
312 ENV.delete('GEM_PATH') if ENV['GEM_PATH']
313 ENV.delete('BUNDLE_GEMFILE') if ENV['BUNDLE_GEMFILE']
314 ENV.delete('BUNDLE_PATH') if ENV['BUNDLE_PATH']
315 ENV.delete('BUNDLE_WITHOUT') if ENV['BUNDLE_WITHOUT']
316
317 $logger.debug "Parsing main_args #{main_args}"
318
319 # verbose already handled
320 main_args.delete('--verbose')
321
322 # Operate on the include option to add to $LOAD_PATH
323 remove_indices = []
324 new_path = []
325 main_args.each_index do |i|
326
327 if main_args[i] == '-I' || main_args[i] == '--include'
328 # remove from further processing
329 remove_indices << i
330 remove_indices << i+1
331
332 dir = main_args[i + 1]
333
334 if dir.nil?
335 $logger.error "#{main_args[i]} requires second argument DIR"
336 return false
337 elsif !File.exist?(dir) || !File.directory?(dir)
338 # DLM: Ruby doesn't warn for this
339 #$logger.warn "'#{dir}' passed to #{main_args[i]} is not a directory"
340 end
341 new_path << dir
342 elsif main_args[i] == '--no-ssl'
343 $logger.warn "'--no-ssl' flag is deprecated"
344 end
345 end
346
347 remove_indices.reverse_each {|i| main_args.delete_at(i)}
348
349 if !new_path.empty?
350
351 new_path = new_path.concat($LOAD_PATH)
352
353 $logger.info "Setting $LOAD_PATH to #{new_path}"
354 $LOAD_PATH.clear
355
356 new_path.each {|p| $LOAD_PATH << p}
357 end
358
359 # Operate on the gem_path option to set GEM_PATH
360 remove_indices = []
361 new_path = []
362 main_args.each_index do |i|
363
364 if main_args[i] == '--gem_path'

Callers 1

executeMethod · 0.85

Calls 15

safe_putsFunction · 0.85
debugMethod · 0.80
directory?Method · 0.80
infoMethod · 0.80
fileNamesMethod · 0.80
add_specMethod · 0.80
messageMethod · 0.80
chdirMethod · 0.80
to_sMethod · 0.80
errorMethod · 0.45
clearMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected