// countersend is the test companion of migadu_counters. "send" plays // mailqueuer (POST /in and /out), "receive" plays the web app and stores every // notification the daemon sends as a file. See docs/testing-with-countersend.md. package main import ( "context" "fmt" "io" "os" "os/signal" "syscall" ) const ( exitOK = 0 exitFail = 1 exitUsage = 2 ) const usage = `Usage: countersend send --route in|out --recipient ADDR [--auth-user ADDR] [--url URL] [--n N] [--concurrency N] ... countersend receive [--listen ADDR] [--dir DIR] Run "countersend send -h" or "countersend receive -h" for all options. ` func main() { ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer stop() os.Exit(run(ctx, os.Args[1:], os.Stdout, os.Stderr, os.Getenv)) } func run(ctx context.Context, args []string, stdout, stderr io.Writer, getenv func(string) string) int { if len(args) == 0 { fmt.Fprint(stderr, usage) return exitUsage } switch args[0] { case "send": return runSend(args[1:], stdout, stderr, getenv) case "receive": return runReceive(ctx, args[1:], stdout, stderr) default: fmt.Fprintf(stderr, "unknown command %q\n\n%s", args[0], usage) return exitUsage } }