Improved command line support

Uses PHP_SAPI to decide CLI block should run
Output JSON that can be parsed by NODE.js in CLI