factor out common cases; split out option parsing / config from actions