How do I write a command help in Java?
If you want to deal with a small number of parameters then you might also just program it by hand. If not, the best way is to use ACS classes CmdLineArgs and CmdLineRegisteredOption. Here is a brief example of the use of the ACS class: import alma.acs.util.CmdLineArgs; import alma.acs.util.CmdLineRegisteredOption; ..... CmdLineArgs cmdArgs = new CmdLineArgs(); CmdLineRegisteredOption optOption = new CmdLineRegisteredOption("-option", 1); cmdArgs.registerOption(optOption); CmdLineRegisteredOption optAnotherOpt = new CmdLineRegisteredOption("-another", "-a", 1); cmdArgs.registerOption(optAnotherOpt); // -- parse and set args try { cmdArgs.parseArgs(args); if (cmdArgs.isSpecified(optOption)) { m_option_value = cmdArgs.getValues(optOption)[0].trim(); } else { //do something } //do the same with the others options }catch (Exception ex){ //throw the Exception } -- CarlitaParedes - 27 Jun 2006 |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|