move specialized cli code out of index.js

For better or worse, the test coverage improves, and I believe it will cause
things to work for testling-ci.