A tool for measuring the coverage of Bluesky/ATProto relays
1require 'optparse'
2
3def parse_options(argv)
4 options = {
5 verbose: false,
6 relays: nil,
7 jetstreams: nil
8 }
9
10 parser = OptionParser.new do |opts|
11 opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
12
13 opts.on('-d', '--duration SECONDS', Integer, 'Duration of the test in seconds') do |seconds|
14 options[:duration] = seconds
15 end
16
17 opts.on('-r', '--relays HOSTS', 'Only connect to these relays; can be comma-separated or passed multiple times') do |hosts|
18 options[:relays] ||= []
19 options[:relays] += hosts.split(',').map(&:strip).reject(&:empty?)
20 end
21
22 opts.on('-j', '--jetstreams HOSTS', 'Only connect to these jetstreams; can be comma-separated or passed multiple times') do |hosts|
23 options[:jetstreams] ||= []
24 options[:jetstreams] += hosts.split(',').map(&:strip).reject(&:empty?)
25 end
26
27 opts.on('-v', '--verbose', 'Report the statistics to stdout during the test') do
28 options[:verbose] = true
29 end
30
31 opts.on('-h', '--help', 'Show help') do
32 puts opts
33 exit 0
34 end
35 end
36
37 parser.parse!(argv)
38
39 options
40rescue OptionParser::ParseError => e
41 warn e.message
42 warn parser
43 exit 1
44end