Add verbose output while running, fix arguments to run.sh

This commit is contained in:
Johan Maasing 2025-04-15 16:57:14 +02:00
parent 98529dd3bd
commit 35ef968ed1
5 changed files with 16 additions and 6 deletions

View file

@ -51,7 +51,7 @@
<version>3.13.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.source}</target>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
@ -91,4 +91,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

View file

@ -61,11 +61,16 @@ public class EndpointsCLI implements Callable<Integer> {
validateTemplateDirectory();
validateInputFile();
validateOutputDirectory();
verbose("Parsing " + file.toAbsolutePath());
DocumentNode rootNode = ParserWrapper.parse(file);
verbose("AST: " + rootNode);
verbose("Generating from templates in: " + templateDir.toAbsolutePath());
Generator generator = new Generator(templateDir, rootNode, outputDir);
List<Path> generatedPaths = generator.generate();
if (generatedPaths.isEmpty()) {
System.out.println("No generated paths found.");
} else {
generatedPaths.forEach(p -> verbose("Generated: " + p.toAbsolutePath()));
}
return 0;
} catch (Exception e) {
@ -74,6 +79,12 @@ public class EndpointsCLI implements Callable<Integer> {
}
}
private void verbose(String message) {
if (this.verbose) {
System.out.println(message);
}
}
private void validateOutputDirectory() throws IOException {
if (Files.notExists(this.outputDir)) {
Files.createDirectories(this.outputDir);