#!/usr/bin/env ruby lib = File.expand_path('../../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'optparse' require 'yaml' require_relative '../lib/splitclient-rb' ARGV << '-h' if ARGV.empty? config_path = '' options = {} opt_parser = OptionParser.new do |opts| opts.banner = "Usage: splitio [options]" opts.on("-cPATH", "--config=PATH", "Set the path to splitio.yml config file") do |c| config_path = c end opts.on("--base-uri=BASE_URI", "Set the base uri for Split SDK") do |c| options[:base_uri] = c end opts.on("--events-uri=EVENTS_URI", "Set the events uri for Split SDK") do |c| options[:events_uri] = c end opts.on("--api-key=API_KEY", "Set the API Key for Split SDK") do |c| options[:api_key] = c end opts.on("--read-timeout=READ_TIMEOUT", "Read timeout in seconds") do |c| options[:read_timeout] = c end opts.on("--connection-timeout=CONNECTION_TIMEOUT", "Connection timeout in seconds") do |c| options[:connection_timeout] = c end opts.on("--features-refresh-rate=FEATURES_REFRESH_RATE", "Features refresh rate in seconds") do |c| options[:features_refresh_rate] = c end opts.on("--segments-refresh-rate=SEGMENTS_REFRESH_RATE", "Segments refresh rate in seconds") do |c| options[:segments_refresh_rate] = c end opts.on("--metrics-refresh-rate=METRICS_REFRESH_RATE", "Metrics refresh rate in seconds") do |c| options[:metrics_refresh_rate] = c end opts.on("--impressions-refresh-rate=IMPRESSIONS_REFRESH_RATE", "Impressions refresh rate in seconds") do |c| options[:impressions_refresh_rate] = c end opts.on("--block-until-ready=SECONDS", "Seconds to block the app until SDK is ready or false to run in non-blocking mode") do |c| options[:block_until_ready] = c end opts.on("--redis-url=REDIS_URL", "Set base uri for Split SDK") do |c| options[:redis_url] = c end opts.on("--transport-debug", "Enable transport debug") do options[:transport_debug_enabled] = true end opts.on("-d", "--debug", "Enable debug mode") do options[:debug_enabled] = true end opts.on_tail("-h", "--help", "Prints this help") do puts opts exit end end begin opt_parser.parse!(ARGV) rescue OptionParser::InvalidOption => e puts e puts opt_parser exit(1) end config = YAML.load_file(config_path) config .merge!(mode: :producer, cache_adapter: :redis) .merge!(options) SplitIoClient::SplitFactory.new(config[:api_key], config)