Cli factored into a callable function