Code review comment: Can we also add that this is to align with non-interactive implementation ?

Code before review:
public void execute() {
PrintStream out = System.out;
Path projectPath = Paths.get(System.getProperty(USER_DIR));
Scanner scanner = new Scanner(System.in, Charset.defaultCharset().name());
try {
Manifest manifest = null;
if (helpFlag) {
String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(INIT_COMMAND);
outStream.println(commandUsageInfo);
return;
}
List<SrcFile> sourceFiles = new ArrayList<>();
List<PackageMdFile> packageMdFiles = new ArrayList<>();
if (interactiveFlag) {
out.print("Create Ballerina.toml [yes/y, no/n]: (y) ");
String createToml = scanner.nextLine().trim();
if (createToml.equalsIgnoreCase("yes") || createToml.equalsIgnoreCase("y") || createToml.isEmpty()) {
manifest = new Manifest();
String defaultOrg = guessOrgName();
out.print("Organization name: (" + defaultOrg + ") ");
String orgName = scanner.nextLine().trim();
manifest.setName(orgName.isEmpty() ? defaultOrg : orgName);
String version;
do {
out.print("Version: (" + DEFAULT_VERSION + ") ");
version = scanner.nextLine().trim();
version = version.isEmpty() ? DEFAULT_VERSION : version;
} while (!validateVersion(out, version));
manifest.setVersion(version);
}
String srcInput;
boolean validInput = false;
boolean firstPrompt = true;
do {
if (firstPrompt) {
out.print("Ballerina source [service/s, main/m, finish/f]: (s) ");
} else {
out.print("Ballerina source [service/s, main/m, finish/f]: (f) ");
}
srcInput = scanner.nextLine().trim();
if (srcInput.equalsIgnoreCase("service") || srcInput.equalsIgnoreCase("s")
|| (srcInput.isEmpty() && firstPrompt)) {
String packageName;
do {
out.print("Package for the service: (no package) ");
packageName = scanner.nextLine().trim();
} while (!validatePkgName(out, packageName));
SrcFile srcFile = new SrcFile(packageName, FileType.SERVICE);
sourceFiles.add(srcFile);
SrcFile srcTestFile = new SrcFile(packageName, FileType.SERVICE_TEST);
sourceFiles.add(srcTestFile);
if (!packageName.isEmpty()) {
PackageMdFile packageMdFile = new PackageMdFile(packageName, FileType.SERVICE);
packageMdFiles.add(packageMdFile);
}
firstPrompt = false;
} else if (srcInput.equalsIgnoreCase("main") || srcInput.equalsIgnoreCase("m")) {
String packageName;
do {
out.print("Package for the main: (no package) ");
packageName = scanner.nextLine().trim();
} while (!validatePkgName(out, packageName));
SrcFile srcFile = new SrcFile(packageName, FileType.MAIN);
sourceFiles.add(srcFile);
SrcFile srcTestFile = new SrcFile(packageName, FileType.MAIN_TEST);
sourceFiles.add(srcTestFile);
if (!packageName.isEmpty()) {
PackageMdFile packageMdFile = new PackageMdFile(packageName, FileType.MAIN);
packageMdFiles.add(packageMdFile);
}
firstPrompt = false;
} else if (srcInput.isEmpty() || srcInput.equalsIgnoreCase("f") ||
srcInput.equalsIgnoreCase("finish")) {
validInput = true;
firstPrompt = false;
} else {
out.println("Invalid input");
}
} while (!validInput);
out.print("\n");
} else {
manifest = new Manifest();
manifest.setName(guessOrgName());
manifest.setVersion(DEFAULT_VERSION);
if (isDirEmpty(projectPath)) {
SrcFile srcFile = new SrcFile("", FileType.SERVICE);
sourceFiles.add(srcFile);
}
}
InitHandler.initialize(projectPath, manifest, sourceFiles, packageMdFiles);
out.println("Ballerina project initialized");
} catch (IOException e) {
out.println("Error occurred while creating project: " + e.getMessage());
}
}


Code after addressing the review:
public void execute() {
PrintStream out = System.out;
Path projectPath = Paths.get(System.getProperty(USER_DIR));
Scanner scanner = new Scanner(System.in, Charset.defaultCharset().name());
try {
Manifest manifest = null;
if (helpFlag) {
String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(INIT_COMMAND);
outStream.println(commandUsageInfo);
return;
}
List<SrcFile> sourceFiles = new ArrayList<>();
List<PackageMdFile> packageMdFiles = new ArrayList<>();
if (interactiveFlag) {
out.print("Create Ballerina.toml [yes/y, no/n]: (y) ");
String createToml = scanner.nextLine().trim();
if (createToml.equalsIgnoreCase("yes") || createToml.equalsIgnoreCase("y") || createToml.isEmpty()) {
manifest = new Manifest();
String defaultOrg = guessOrgName();
out.print("Organization name: (" + defaultOrg + ") ");
String orgName = scanner.nextLine().trim();
manifest.setName(orgName.isEmpty() ? defaultOrg : orgName);
String version;
do {
out.print("Version: (" + DEFAULT_VERSION + ") ");
version = scanner.nextLine().trim();
version = version.isEmpty() ? DEFAULT_VERSION : version;
} while (!validateVersion(out, version));
manifest.setVersion(version);
}
String srcInput;
boolean validInput = false;
boolean firstPrompt = true;
do {
if (firstPrompt) {
out.print("Ballerina source [service/s, main/m, finish/f]: (s) ");
} else {
out.print("Ballerina source [service/s, main/m, finish/f]: (f) ");
}
srcInput = scanner.nextLine().trim();
if (srcInput.equalsIgnoreCase("service") || srcInput.equalsIgnoreCase("s")
|| (srcInput.isEmpty() && firstPrompt)) {
String packageName;
do {
out.print("Package for the service: (no package) ");
packageName = scanner.nextLine().trim();
} while (!validatePkgName(out, packageName));
SrcFile srcFile = new SrcFile(packageName, FileType.SERVICE);
sourceFiles.add(srcFile);
SrcFile srcTestFile = new SrcFile(packageName, FileType.SERVICE_TEST);
sourceFiles.add(srcTestFile);
if (!packageName.isEmpty()) {
PackageMdFile packageMdFile = new PackageMdFile(packageName, FileType.SERVICE);
packageMdFiles.add(packageMdFile);
}
firstPrompt = false;
} else if (srcInput.equalsIgnoreCase("main") || srcInput.equalsIgnoreCase("m")) {
String packageName;
do {
out.print("Package for the main: (no package) ");
packageName = scanner.nextLine().trim();
} while (!validatePkgName(out, packageName));
SrcFile srcFile = new SrcFile(packageName, FileType.MAIN);
sourceFiles.add(srcFile);
SrcFile srcTestFile = new SrcFile(packageName, FileType.MAIN_TEST);
sourceFiles.add(srcTestFile);
if (!packageName.isEmpty()) {
PackageMdFile packageMdFile = new PackageMdFile(packageName, FileType.MAIN);
packageMdFiles.add(packageMdFile);
}
firstPrompt = false;
} else if (srcInput.isEmpty() || srcInput.equalsIgnoreCase("f") ||
srcInput.equalsIgnoreCase("finish")) {
validInput = true;
firstPrompt = false;
} else {
out.println("Invalid input");
}
} while (!validInput);
out.print("\n");
} else {
manifest = new Manifest();
manifest.setName(guessOrgName());
manifest.setVersion(DEFAULT_VERSION);
if (isDirEmpty(projectPath)) {
SrcFile srcFile = new SrcFile("", FileType.SERVICE);
sourceFiles.add(srcFile);
}
}
InitHandler.initialize(projectPath, manifest, sourceFiles, packageMdFiles);
out.println("Ballerina project initialized");
} catch (IOException e) {
out.println("Error occurred while creating project: " + e.getMessage());
}
}