Print

Print


Author: [log in to unmask]
Date: Tue Dec  8 20:42:25 2015
New Revision: 3692

Log:
Make definition of CL options accessible to sub-classes.

Modified:
    projects/lcsim/branches/jeremy-dev/job-manager/src/main/java/org/lcsim/job/JobControlManager.java

Modified: projects/lcsim/branches/jeremy-dev/job-manager/src/main/java/org/lcsim/job/JobControlManager.java
 =============================================================================
--- projects/lcsim/branches/jeremy-dev/job-manager/src/main/java/org/lcsim/job/JobControlManager.java	(original)
+++ projects/lcsim/branches/jeremy-dev/job-manager/src/main/java/org/lcsim/job/JobControlManager.java	Tue Dec  8 20:42:25 2015
@@ -87,7 +87,7 @@
     /**
      * The command line options.
      */
-    private static final Options OPTIONS = createCommandLineOptions();
+    private Options options;
 
     /**
      * The regular expression for extracting the variables from an XML file.
@@ -99,8 +99,8 @@
      *
      * @return The command line options for the manager.
      */
-    private static Options createCommandLineOptions() {
-        final Options options = new Options();
+    protected Options createCommandLineOptions() {
+        options = new Options();
         options.addOption(new Option("h", "help", false, "Print help and exit"));
         options.addOption(new Option("p", "properties", true, "Load a properties file containing variable definitions"));
         options.addOption(new Option("D", "define", true, "Define a variable with form [name]=[value]"));
@@ -116,7 +116,11 @@
         options.addOption(new Option("R", "run", true, "user supplied run number (careful!)"));
         return options;
     }
-
+    
+    public Options getOptions() {
+        return options;
+    }
+        
     /**
      * Get the Java primitive type class from a type name.
      *
@@ -170,10 +174,10 @@
     /**
      * Print help and exit.
      */
-    private static void printHelp() {
+    private void printHelp() {
         LOGGER.info("java " + JobControlManager.class.getCanonicalName() + " [options] steeringFile.xml");
         final HelpFormatter help = new HelpFormatter();
-        help.printHelp(" ", OPTIONS);
+        help.printHelp(" ", options);
         System.exit(1);
     }
 
@@ -504,16 +508,19 @@
      *
      * @param args The command line arguments.
      */
-    public void parse(final String args[]) {
+    public CommandLine parse(final String args[]) {
         
         LOGGER.config("parsing command line arguments");
 
+        // Create command line options.
+        createCommandLineOptions();
+        
         // Setup parser.
         final CommandLineParser parser = new PosixParser();
 
         // Parse the command line arguments.
         try {
-            commandLine = parser.parse(OPTIONS, args);
+            commandLine = parser.parse(options, args);
         } catch (final ParseException x) {
             throw new RuntimeException("Problem parsing command line options.", x);
         }
@@ -664,6 +671,8 @@
             LOGGER.config("initializing from steering file " + xmlRunControlFile.getPath());
             this.setup(xmlRunControlFile);
         }
+        
+        return commandLine;
     }
 
     /**

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1