public class CommandLineOptions {
@Arg(description = "Input file", required = true)
private String inputFile;
@Arg(description = "Output file", required = true)
private String outputFile;
// Getter and Setter
}
ArgsParser parser = new ArgsParser();
CommandLineOptions options = parser.parse(CommandLineOptions.class, args);
public class CommandLineOptions {
@Arg(description = "Input file", required = true, validate = "validateInputFile")
private String inputFile;
// Getter and Setter
public boolean validateInputFile(String value) {
File file = new File(value);
return file.exists();
}
}
public class Main {
public static void main(String[] args) {
ArgsParser parser = new ArgsParser();
CommandLineOptions options = parser.parse(CommandLineOptions.class, args);
// Access the parsed command line options
String inputFile = options.getInputFile();
String outputFile = options.getOutputFile();
// Your application logic here
}
}
public class CommandLineOptions {
@Arg(description = "Input file", required = true)
private String inputFile;
@Arg(description = "Output file", required = true)
private String outputFile;
// Getter and Setter
}