the section of code:
Options options = new Options();
options.addOption("h", "help", false, "prints the help content");
options.addOption("f", "fileType", true, "file type");
options.addOption("u", "url", true, "url");
options.addOption("d", "validDate", true, "valid date");
LoadReferenceFileRequest request=new LoadReferenceFileRequest();
LoadReferenceFileResponse response=new LoadReferenceFileResponse();
try{
//Etape 2: Analyse de la ligne de commande
CommandLineParser parser = new DefaultParser();
CommandLine commandLine = parser.parse(options, args);
if(commandLine.hasOption("f") && commandLine.hasOption("u") && commandLine.hasOption("d")) {
String fileType = commandLine.getOptionValue('f');
request.setFileType(fileType);
String url = commandLine.getOptionValue('u');
request.setUrl(url);
String validDate = commandLine.getOptionValue('d');
request.setValidDate(validDate);
loadReferenceFileClientService.validateRequest(request,response);
loadReferenceFileClientService.invokeInternal(request,response);
}else {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( "App" , options );
System.exit(1);
}
Error description and command used to execute the code :
java -classpath MyClassPath -f .xml -usr/local/data/osmiumspa/ref/channel.xml -d 20180905 The error:
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
%d [%thread] %-5level %logger - %msg%n%d [%thread] %-5level %logger - %msg%nError while parsing the command line: Unrecognized option: -f
issue seems to be at CommandLineParser parser = new DefaultParser();
use CommandLineParser parser = new GnuParser();
which would resolve this issue