factor out common code for run and atmos:run
add 0.13 support for atmos:run-main