arg4j option but no params

Viewed 15

I am trying to create a command line application using arg4j, I was able to do it using Apache CLI with ease but when using arg4j, it is causing trouble.

I need to create a command line tool which will accept

java -jar demo.jar -username johndoe -password pass123 -export

If you see, for username and password I gave params, but for -export (it is required) and when I do "-export" it will connect to DB and do some stuffs.

I used apache cli and it was fairly simple to use with good documentation.

Option startExportFromDbToJson = new Option("export", false, "use <-export> to begin the export\n");
    startExportFromDbToJson.setRequired(true);
    options.addOption(startExportFromDbToJson);

So if you see, in this is just passed a false (which means it has not param)

Can I do it in Arg4j, can I create fields like -username -filepath and not use pre defined fields?

0 Answers
Related