#!/usr/bin/env ruby $LOAD_PATH.unshift File.join(__dir__, '../lib') ENV["SCOUT_NOCOLOR"] = "true" if ARGV.include? "--nocolor" ENV["SCOUT_NO_PROGRESS"] = "true" if ARGV.include? "--nobar" require 'scout-gear' class CmdStop < Exception attr_accessor :exit_status def initialize(exit_status = 0) @exit_status = exit_status end end # Add paths to scout repos under --dev to LOAD_PATHS dev_dir = nil if _i = ARGV.index("--dev") dev_dir = ARGV[_i+1] ARGV.delete "--dev" ARGV.delete dev_dir 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.nil? && ENV["SCOUT_DEV"] dev_dir = ENV["SCOUT_DEV"] ARGV.delete "--dev" ARGV.delete dev_dir end if dev_dir ['scout-*/lib'].each do |pattern| Dir.glob(File.join(File.expand_path(dev_dir), pattern)).each do |f| $LOAD_PATH.unshift f end end ['rbbt-*/lib'].each do |pattern| Dir.glob(File.join(File.expand_path(dev_dir), pattern)).each do |f| $LOAD_PATH.unshift f end end end require 'scout' require 'scout/simple_opt' 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"} --nocolor #{Log.color :yellow, "Disable colored output"} --nobar #{Log.color :yellow, "Disable progress report"} --locate_file #{Log.color :yellow, "Report the location of the script instead of executing it"} -ck--config_keys* #{Log.color :yellow, "Override some config keys"} EOF Log.nocolor = true if options[:nocolor] locate = options.delete :locate_file if options[:log_file] Log.logfile(options.delete(:log_file)) end if options[:log] Log.severity = options.delete(:log).to_i else global_severity = Log.get_level(Scout.etc.log_severity.read.strip) if Scout.etc.log_severity.exists? if ENV["SCOUT_LOG"] Log.severity = ENV["SCOUT_LOG"].to_i else global_severity = Log.get_level(Scout.etc.log_severity.read.strip) if Scout.etc.log_severity.exists? Log.severity = global_severity.to_i if global_severity end end if config_keys = options.delete(:config_keys) config_keys.split(",").each do |config| config = config.strip Scout::Config.process_config config end end $scout_command_dir = Scout.bin.scout $scout_command_dir.path_maps[:scout_commands] = File.join(File.dirname(__dir__), "{PATH/bin\\/scout/scout_commands}") SOPT.description =< 10) end end exit exit_status