#!/usr/bin/env ruby dev_dir = nil if _i = ARGV.index("--dev") dev_dir = ARGV[_i+1] ARGV.delete "--dev" end if dev_dir.nil? _s = nil ARGV.each_with_index do |s,i| if s.match(/^--dev(?:=(.*))?/) dev_dir = $1 _s = s next end end ARGV.delete _s if _s end if dev_dir Dir.glob(File.join(File.expand_path(dev_dir),'rbbt-*/lib')).each do |f| $LOAD_PATH.unshift f end end require 'rbbt' require 'rbbt/util/simpleopt' Log.nocolor = true if ARGV.include? "--nocolor" options = SOPT.setup < ... -a --arg1 --arg2='value' --arg3 'another-value'" --log* #{Log.color :yellow, "Log level from 0 (debug) 6 (errors)"} --dev* #{Log.color :yellow, "Find development libraries in the directory specified"} -cd--command_dir* #{Log.color :yellow, "Directory from where to load command scripts"} --profile #{Log.color :yellow, "Profile execution"} --nocolor #{Log.color :yellow, "Disable colored output"} --nobar #{Log.color :yellow, "Disable progress report"} --nostream #{Log.color :yellow, "Disable persistance/job streaming"} --locate_file #{Log.color :yellow, "Report the location of the script instead of executing it"} --dump_mem* #{Log.color :yellow, "Dump strings in memory each second into file"} --no_lock_id #{Log.color :yellow, "Do not track lockfiles with ids (for high-througput and high-concurrency"} EOF locate = options.delete :locate_file if options[:log] Log.severity = options[:log].to_i else global_severity = Log.get_level(Rbbt.etc.log_severity.read.strip) if Rbbt.etc.log_severity.exists? if ENV["RBBT_LOG"] Log.severity = ENV["RBBT_LOG"].to_i else global_severity = Log.get_level(Rbbt.etc.log_severity.read.strip) if Rbbt.etc.log_severity.exists? Log.severity = global_severity.to_i if global_severity end end if options.delete(:no_lock_id) Misc.use_lock_id = false end if mem_dump = options.delete(:dump_mem) require 'rbbt/monitor' Rbbt.dump_memory(mem_dump, Symbol) end if options.delete :nostream ENV["RBBT_NO_STREAM"] = "true" end if options.delete :nobar ENV["RBBT_NO_PROGRESS"] = "true" end if options[:command_dir] $rbbt_command_dir = Path.setup(options[:command_dir].dup) else $rbbt_command_dir = Rbbt.share.rbbt_commands end SOPT.description =< 10) end end