A tool for measuring the coverage of Bluesky/ATProto relays
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

extracted option parsing to another file

+32 -18
+28
opts.rb
··· 1 + require 'optparse' 2 + 3 + def parse_options(argv) 4 + options = { 5 + verbose: false 6 + } 7 + 8 + parser = OptionParser.new do |opts| 9 + opts.banner = "Usage: #{$PROGRAM_NAME} [options]" 10 + 11 + opts.on('-v', '--verbose', 'Report the statistics to stdout during the test') do 12 + options[:verbose] = true 13 + end 14 + 15 + opts.on('-h', '--help', 'Show help') do 16 + puts opts 17 + exit 0 18 + end 19 + end 20 + 21 + parser.parse!(argv) 22 + 23 + options 24 + rescue OptionParser::ParseError => e 25 + warn e.message 26 + warn parser 27 + exit 1 28 + end
+4 -18
run_test.rb
··· 4 4 require 'skyfall' 5 5 require 'yaml' 6 6 7 + require_relative 'opts' 8 + 7 9 SOURCES = 'config/sources.yml' 8 10 9 11 config = YAML.load(File.read(SOURCES)) ··· 13 15 duration = config['duration']&.to_i || 60 * 15 14 16 15 17 maxlen = (relays + jetstreams).map(&:length).max 16 - verbose = false 17 18 18 - def print_help 19 - puts "Usage: #{$PROGRAM_NAME} [-v]" 20 - end 21 - 22 - ARGV.each do |param| 23 - case param 24 - when '-h', '--help' 25 - print_help 26 - exit 0 27 - when '-v', '--verbose' 28 - verbose = true 29 - else 30 - puts "Unknown option: #{param}" 31 - print_help 32 - exit 1 33 - end 34 - end 19 + options = parse_options(ARGV) 20 + verbose = options[:verbose] 35 21 36 22 Worker = Struct.new(:host, :pid, :pipe) 37 23 workers = []