parse the main args, those that come before the sub command
(main_args)
| 305 | |
| 306 | # parse the main args, those that come before the sub command |
| 307 | def 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' |
no test coverage detected