refactor waitForInput in CommandLine class.