package org.semanticweb.clipper.hornshiq.cli;

import com.beust.jcommander.JCommander;
import org.semanticweb.clipper.hornshiq.queryanswering.ClipperManager;

public class ClipperApp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new ClipperApp(args);
	}

	public ClipperApp(String[] args) {
		CommandLineArgs co = new CommandLineArgs();
		JCommander jc = new JCommander(co);

		CommandQuery commandQuery = new CommandQuery(jc);

		CommandRewrite commandRewrite = new CommandRewrite(jc);

		CommandHelp commandHelp = new CommandHelp(jc);

		CommandLoad commandLoad = new CommandLoad(jc);

		CommandInitDB commandInitDB = new CommandInitDB(jc);

		CommandGenerateMapFile commandGenerateMapFile = new CommandGenerateMapFile(
				jc);
		
		CommandSparqlToSQL commandSparqlToSQL = new CommandSparqlToSQL(jc);

		CommandPythonOntology commandPythonOntology = new CommandPythonOntology(jc);
		
		jc.setProgramName("clipper.sh");

		jc.parse(args);

		ClipperManager.getInstance().setVerboseLevel(co.getVerbose());

		String cmd = null;
		try {
			cmd = jc.getParsedCommand();
		} catch (Exception ex) {
			System.err.println(ex.getMessage());
			commandHelp.exec();
		}

		if (cmd == null) {
			commandHelp.exec();
		} else if (cmd.equals("query")) {
			commandQuery.exec();
		} else if (cmd.equals("rewrite")) {
			commandRewrite.exec();
		} else if (cmd.equals("load")) {
			commandLoad.exec();
		} else if (cmd.equals("init")) {
			commandInitDB.exec();
		} else if (cmd.equals("help")) {
			commandHelp.exec();
		} else if (cmd.equals("gen")) {
			commandGenerateMapFile.exec();
		} else if (cmd.equals("pex")) {
			commandPythonOntology.exec();
		} else if (cmd.endsWith("sparql2sql")){
			commandSparqlToSQL.exec();
		}
	}

}

@@ -183,34 +183,8 @@
  %7B%0A%0A
-%09/**%0A%09 * @param args%0A%09 */%0A
 %09pub
@@ -221,16 +221,16 @@
 args) %7B%0A
+
 %09%09new Cl
@@ -528,24 +528,26 @@
 dHelp(jc);%0A%0A
+//
 %09%09CommandLoa
@@ -579,25 +579,29 @@
 ndLoad(jc);%0A
-%0A
+//%0A//
 %09%09CommandIni
@@ -639,25 +639,29 @@
 InitDB(jc);%0A
-%0A
+//%0A//
 %09%09CommandGen
@@ -729,21 +729,18 @@
 ile(
-%0A%09%09%09%09jc);%0A%09%09%0A
+jc);%0A//%0A//
 %09%09Co
@@ -801,25 +801,29 @@
 lToSQL(jc);%0A
-%0A
+//%0A//
 %09%09CommandPyt
@@ -1332,32 +1332,42 @@
 rite.exec();%0A%09%09%7D
+%0A//       
  else if (cmd.eq
@@ -1378,24 +1378,26 @@
 (%22load%22)) %7B%0A
+//
 %09%09%09commandLo
@@ -1399,32 +1399,34 @@
 andLoad.exec();%0A
+//
 %09%09%7D else if (cmd
@@ -1440,24 +1440,26 @@
 (%22init%22)) %7B%0A
+//
 %09%09%09commandIn
@@ -1463,32 +1463,34 @@
 dInitDB.exec();%0A
+//
 %09%09%7D else if (cmd
@@ -1504,24 +1504,26 @@
 (%22help%22)) %7B%0A
+//
 %09%09%09commandHe
@@ -1525,32 +1525,34 @@
 andHelp.exec();%0A
+//
 %09%09%7D else if (cmd
@@ -1565,24 +1565,26 @@
 s(%22gen%22)) %7B%0A
+//
 %09%09%09commandGe
@@ -1597,32 +1597,34 @@
 MapFile.exec();%0A
+//
 %09%09%7D else if (cmd
@@ -1637,24 +1637,26 @@
 s(%22pex%22)) %7B%0A
+//
 %09%09%09commandPy
@@ -1668,32 +1668,34 @@
 ntology.exec();%0A
+//
 %09%09%7D else if (cmd
@@ -1720,16 +1720,18 @@
 sql%22))%7B%0A
+//
 %09%09%09comma
@@ -1748,22 +1748,24 @@
 SQL.exec();%0A
+//
 %09%09%7D%0A%09%7D%0A%0A%7D%0A

comment out unused commands