main(argv)
click to toggle source
# File examples/run_examples.rb, line 30 def main(argv) credentials = { :host => "localhost", :port => 8089, :username => "admin", :password => "changeme", } parser = OptionParser.new do |op| op.on("--host HOSTNAME", String, "Set Splunk host (default: localhost)") do |s| credentials[:host] = s end op.on("--port PORT", Integer, "Set Splunk port (default: 8089)") do |p| credentials[:port] = p end op.on("--username USERNAME", String, "Set username for login (default: admin)") do |s| credentials[:username] = s end op.on("--password PASSWORD", String, "Set password for login (default: changeme)") do |s| credentials[:password] = s end end parser.parse!(argv) # The examples are all named as 1_something.rb, 2_something.rb in the same # directory as this script. example_path = File.dirname(File.expand_path(__FILE__)) example_files = Dir.entries(example_path). select() {|s| s.match('^\d_.+\.rb')}. map() {|s| File.join(example_path, s)} # Add the path to the Splunk SDK for Ruby. $LOAD_PATH.push(File.join(File.dirname(example_path), "lib")) # Run example_files.each do |p| run_example(p, credentials) end end