Split the CLI out to a main module that can be called programmatically leaving the CLI purely responsible for parsing args and executing the main module.