Refactor CLI parsing into cli.js module