Refactor the CLI class to make it easy for re-use by other client.