<dependency>
<groupId>com.lexicalscope.jewelcli</groupId>
<artifactId>jewelcli</artifactId>
<version>0.8.9</version>
</dependency>
groovy
implementation 'com.lexicalscope.jewelcli:jewelcli:0.8.9'
public class CommandLineArgs {
@Option(shortName = "i", longName = "input", description = "Input file")
public String inputFile;
@Option(shortName = "o", longName = "output", description = "Output file")
public String outputFile;
@Option(shortName = "v", longName = "verbose", description = "Verbose mode")
public boolean verbose;
}
public class App {
public static void main(String[] args) {
try {
CommandLineArgs commandLineArgs = CliFactory.parseArguments(CommandLineArgs.class, args);
if (commandLineArgs.verbose) {
System.out.println("Verbose mode is enabled.");
}
} catch (ArgumentException e) {
CliFactory.printHelp(CommandLineArgs.class);
}
}
}
try {
CommandLineArgs commandLineArgs = CliFactory.parseArguments(CommandLineArgs.class, args);
if (commandLineArgs.verbose) {
System.out.println("Verbose mode is enabled.");
}
} catch (ArgumentException e) {
CliFactory.printHelp(CommandLineArgs.class);
}