extracting logic of cli file into lib/cli.js