use of com.bluenimble.platform.icli.mgm.commands.mgm.RemoteCommand in project serverless by bluenimble.
the class BlueNimble method loadCommands.
private void loadCommands(File commands) {
if (!commands.exists() || !commands.isDirectory()) {
commands.mkdir();
return;
}
File[] folders = commands.listFiles(new FileFilter() {
@Override
public boolean accept(File f) {
return f.isDirectory();
}
});
for (File fld : folders) {
String ctx = fld.getName();
if (GlobalContext.equals(ctx)) {
ctx = Tool.ROOT_CTX;
} else {
ToolContext toolContext = getContext(ctx);
if (toolContext == null) {
addContext(new ToolContextImpl(ctx));
}
}
File[] files = fld.listFiles(new FileFilter() {
@Override
public boolean accept(File f) {
return f.isFile() && f.getName().endsWith(".json");
}
});
String name = null;
for (File f : files) {
name = f.getName().substring(0, f.getName().indexOf(JsonExt));
try {
addCommand(new RemoteCommand(ctx, name, Json.load(f)));
} catch (Exception e) {
System.out.println("ERROR: Can't load command " + name + ". Cause: " + e.getMessage());
}
}
}
}
Aggregations