Extract actual work from generateClient so that we can call it without killing the JVM.

We wanted to run generateClient as part of a sbt task, but the existing method was killing sbt due to System.exit(0). We extracted the actual logic into a separate method that we can call from sbt.

Not sure what the original reason for calling System.exit(0) was, but assuming it was put there for a reason and not removing it for backwards compatibility.