Building the command-line interface
In the last chapter, we built a command-line tool using the Crest library from Tomitribe, and it worked out pretty well, so we will return to the library in building this command line as well.
To enable Crest in our project, we must do two things. First, we have to configure our POM file as follows:
<dependency> <groupId>org.tomitribe</groupId> <artifactId>tomitribe-crest</artifactId> <version>0.8</version> </dependency>
We must also update our module definition in src/main/java/module-info.java
as follows:
module datecalc.cli { requires datecalc.lib; requires tomitribe.crest; requires tomitribe.crest.api; exports com.steeplesoft.datecalc.cli; }
We can now define our CLI class like this:
public class DateCalc { @Command public void dateCalc(String... args) { final String expression = String.join(" ", args); ...