Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.OFF);
Logger.getLogger("com.k42b3.kadabra").setLevel(Level.OFF);
// start kadabra
Console console = System.console();
Kadabra instance = new Kadabra();
if(args.length == 2 && args[0].equals("status"))
{
int id = Integer.parseInt(args[1]);
instance.status(id);
}
else if(args.length == 2 && args[0].equals("release"))
{
int id = Integer.parseInt(args[1]);
instance.release(id);
}
else if(args.length == 1 && args[0].equals("list"))
{
instance.listProject();
}
else if(args.length == 2 && args[0].equals("list") && args[1].equals("resource"))
{
instance.listResource();
}
else if(args.length == 1 && args[0].equals("add"))
{
String name = console.readLine("Name: ");
String leftPath = console.readLine("Left path: ");
int legtResourceId = Integer.parseInt(console.readLine("Left resource id: "));
String rightPath = console.readLine("Right path: ");
int rightResourceId = Integer.parseInt(console.readLine("Right resource id: "));
instance.addProject(name, leftPath, legtResourceId, rightPath, rightResourceId);
}
else if(args.length == 2 && args[0].equals("add") && args[1].equals("resource"))
{
String type = console.readLine("Type [System|Ftp|Ssh]: ").toUpperCase();
HashMap<String, String> config = new HashMap<String, String>();
ArrayList<String> configFields = HandlerFactory.factoryConfig(type);
String name = console.readLine("Name: ");
for(int i = 0; i < configFields.size(); i++)
{
String key = configFields.get(i);
String value = console.readLine(key + ": ");
config.put(key, value);
}
instance.addResource(type, name, config);
}
else if(args.length == 2 && args[0].equals("add") && args[1].equals("exclude"))
{
int projectId = Integer.parseInt(console.readLine("Project ID: "));
String pattern = console.readLine("Pattern: ");
instance.addExclude(projectId, pattern);
}
else if(args.length == 1 && args[0].equals("del"))
{
int projectId = Integer.parseInt(console.readLine("Project ID: "));
instance.deleteProject(projectId);
}
else if(args.length == 2 && args[0].equals("del") && args[1].equals("resource"))
{
int resourceId = Integer.parseInt(console.readLine("Resource ID: "));
instance.deleteResource(resourceId);
}
else if(args.length == 2 && args[0].equals("del") && args[1].equals("exclude"))
{
int excludeId = Integer.parseInt(console.readLine("Exclude ID: "));
instance.deleteExclude(excludeId);
}
else if(args.length == 1 && args[0].equals("build"))
{