Cleanup: extract some stuff to a method in CreateCLI.