Java GetOpt Generator is a software that generates a command-line argument parser from an XML file.
Both a 'parser' and 'config' class are generated, which allows your program to either be launched from the command-line or programmatically configured and executed from another Java application.
GetOpt Generator is Self-Hosting meaning it uses itself to generate its command-line parser.
You can look at GetOpt.xml, the XML used by GetOpt to generate its own command-line parser, for an example of what the XML configuration file should look like.
Basically each option gets:
Long name of the option. Separate logical words with "_" (i.e. long_opt)
Short (1 char) alias for the option
· input-file (verifies that file exists)
· input-dir (verifies that dir exists)
· output-file (treated as string for now)
· output-dir (treated as string for now)
Calling GetOpt with --help generates the following output
options for GetOpt :
[ --help | -? ]
( --xmlFile | -x ) xml_file
( --javaDir | -j ) java_dir
( --exeClass | -e ) exe_class
( --mainClass | -m ) main_class
( --configClass | -c ) config_class
NOTE: Options in brackets '' are optional.
All camel-case long opts can be represented using lowercase,
as well as with '-' or '_' seperating the camel-cased words
(i.e. --longOpt | --longopt | --long_opt | --long-opt)
The XML file containing the configuration
The fully qualified name (package+class) of the generated class that will parse the command line (i.e. contains the main() method).
The fully qualified name (package_class) of the generated class that will store the config information.
The base output directory (i.e. your src directory). The generated files will be stored in /java/dir/package/path/ClassName.java
The Java class that the generated command-line parser should call after parsing the command line.
The exe class is expected to contain a constructor that accepts a config_class instance.
The exe class is expected to contain an execute() method, which will be called by the command-line parser.
It is the responsibility of the exe class to validate the parsed config, but the config_class is generated with a validate() function which does the heavy lifting.