Skip to content

Commit

Permalink
More improvements to create operation
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Dec 27, 2024
1 parent 3d86aa8 commit 2dd53ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core
10 changes: 8 additions & 2 deletions src/main/java/rife/bld/operations/AbstractCreateOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,17 +393,20 @@ public T fromArguments(List<String> arguments) {
if (package_name == null || package_name.isBlank()) {
System.out.println("Please enter a package name (for instance: com.example):");
package_name = System.console().readLine();
if (package_name == null || package_name.isEmpty()) {
if (package_name == null || package_name.isBlank()) {
throw new OperationOptionException("ERROR: package name is required.");
}
} else {
System.out.println("Using package name: " + package_name);
}
if (!ValidityChecks.checkJavaPackage(package_name)) {
throw new OperationOptionException("ERROR: package name is invalid.");
}

if (project_name == null || project_name.isBlank()) {
System.out.println("Please enter a project name (for instance: my-app):");
project_name = System.console().readLine();
if (project_name == null || project_name.isEmpty()) {
if (project_name == null || project_name.isBlank()) {
throw new OperationOptionException("ERROR: project name is required.");
}
} else {
Expand All @@ -421,6 +424,9 @@ public T fromArguments(List<String> arguments) {
} else {
System.out.println("Using base name: " + base_name);
}
if (!ValidityChecks.checkJavaIdentifier(base_name)) {
throw new OperationOptionException("ERROR: base name is invalid.");
}

return workDirectory(new File(System.getProperty("user.dir")))
.packageName(package_name)
Expand Down

0 comments on commit 2dd53ac

Please sign in to comment.