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

@ -33,7 +33,7 @@ parser and a code generator using [freemarker](https://freemarker.apache.org).
\____________________\
```
## How to Run
You need a Java 24 runtime and java in the path. A very convenient way to install a java runtime is [SdkMan](https://sdkman.io).
You need a Java 21 (or later) runtime and java in the path. A very convenient way to install a java runtime is [SdkMan](https://sdkman.io).
Unpack the archive, run the provided shellscript file.

View file

@ -1,4 +1,4 @@
#! /bin/sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "${SCRIPT_DIR}"
java -jar parser-${artifact.baseVersion}.jar
java -jar parser-${artifact.baseVersion}.jar "$@"

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>

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);

View file

@ -17,8 +17,7 @@
{
some: configvalue,
someother: value,
package: se.rutdev.senash,
ending: .scala
package: se.rutdev.senash
}
/some/endpoint <- SomeType(foo:String)