Revision: 1793
Author: [email protected]
Date: Fri Dec 18 17:21:59 2009
Log: Allow the addition of multiple projects from the command line  
with "importOhloh -f filename" where filename points to a file where each  
line is an ohloh project ID or a comment (starting with '#')
http://code.google.com/p/simal/source/detail?r=1793

Modified:
   
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/Simal.java

=======================================
---  
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/Simal.java  
 
Wed Dec  9 14:09:19 2009
+++  
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/Simal.java  
 
Fri Dec 18 17:21:59 2009
@@ -99,6 +99,10 @@
          "When displaying resource information only display summary  
details.");
      opts.addOption(summary);

+    Option filename = new Option("f", "filename", true,
+        "The filename to use for this command.");
+    opts.addOption(filename);
+
      Option test = new Option(
          "t",
          "test",
@@ -219,14 +223,24 @@
          }
          i++;
        } else if (cmd.equals("importOhloh")) {
-        try {
-          importOhloh((String) cmds[i + 1]);
-        } catch (SimalException e) {
-          logger.error("Unable to Import from Ohloh: " + e.getMessage()  
+ "\n",
-              e);
-          System.exit(1);
-        }
-        i++;
+         try {
+           if (cl.hasOption('f')) {
+                   String filename = cl.getOptionValue('f');
+                               File file = new File(filename);
+                   importOhloh(file);
+           } else {
+                 importOhloh((String) cmds[i + 1]);
+           }
+            i++;
+         } catch (SimalException e) {
+                   logger.error("Unable to Import from Ohloh: " + 
e.getMessage()  
+ "\n",
+                        e);
+            System.exit(1);
+          } catch (IOException e) {
+            logger.error("Unable to Import from Ohloh: " + e.getMessage()  
+ "\n",
+                    e);
+            System.exit(1);
+                 }
        } else if (cmd.equals(CMD_BACKUP)) {
          i++;
          backup(cmds, i);
@@ -350,6 +364,17 @@
      Ohloh ohloh = new Ohloh();
      ohloh.addProjectToSimal(id);
    }
+
+  /**
+   * Import multiple projects from Ohloh. Each project is listed in the  
file supplied.
+   *
+   * @param file
+   * @throws IOException
+   */
+  private static void importOhloh(File file) throws SimalException,  
IOException {
+    Ohloh ohloh = new Ohloh();
+    ohloh.importProjects(file);
+  }

    /**
     * Import all the documents updated since the last time we updated from  
PTSW.
@@ -494,7 +519,7 @@
      commandSummary
          .append("getProjects                get all projects, or those  
indicated in the options.\n\n");
      commandSummary
-        .append("importOhloh  ID            import a project from Ohloh  
with a given ID.\n\n");
+        .append("importOhloh  FILE_OR_ID    import a project from Ohloh  
with a given ID.\n\n");
      commandSummary
          .append("importPTSW                 Import all recently updated  
DOAP files from PTSW\n\n");
      commandSummary

--

You received this message because you are subscribed to the Google Groups 
"Simal Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simal-commits?hl=en.


Reply via email to