Move main logic from cli.js to semigrate.js