From b6b809207b1bf0730fc010d4cc08a030b636fe89 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Thu, 23 Mar 2023 19:41:03 +0100 Subject: Add options --- internal/options/options.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 internal/options/options.go (limited to 'internal/options/options.go') diff --git a/internal/options/options.go b/internal/options/options.go new file mode 100644 index 0000000..f7510ba --- /dev/null +++ b/internal/options/options.go @@ -0,0 +1,22 @@ +package options + +import ( + "flag" + "time" +) + +type Options struct { + InputFile string + NumWorkers int + MetricsInterval time.Duration + Timeout time.Duration +} + +func Parse() (opts Options) { + flag.StringVar(&opts.InputFile, "i", "lists/small.lst", "input file, one domain name per line") + flag.IntVar(&opts.NumWorkers, "w", 10, "number of parallel workers") + flag.DurationVar(&opts.Timeout, "t", 10*time.Second, "timeout for each website visit") + flag.DurationVar(&opts.MetricsInterval, "m", 5*time.Second, "how often to emit metrics") + flag.Parse() + return +} -- cgit v1.2.3