in util/src/main/java/com/epam/deltix/util/cmdline/AbstractShell.java [177:245]
public final void runCommand (String key, String args, String fileId, LineNumberReader rd) {
key = key.trim ();
if (args != null && args.length () == 0) // eliminate check
args = null;
Method m = null;
int sig = -1;
String mname = "cmd_" + key;
try {
m = getClass ().getMethod (mname, String.class, String.class, LineNumberReader.class);
sig = 3;
} catch (NoSuchMethodException x) {
}
if (m == null) {
try {
m = getClass ().getMethod (mname, String.class);
sig = 1;
} catch (NoSuchMethodException x) {
}
}
if (m == null) {
try {
m = getClass ().getMethod (mname);
sig = 0;
} catch (NoSuchMethodException x) {
}
}
try {
switch (sig) {
case -1:
boolean result;
try {
result = doCommand (key, args, fileId, rd);
} catch (ShellCommandException e) {
result = true; // Command was recognized but failed to complete
error (e.getMessage(), e.getErrorLevel());
}
if (!result)
error (key + ": unrecognized command. (Type ? for usage)", 1);
break;
case 3:
m.invoke (this, args, fileId, rd);
break;
case 1:
m.invoke (this, args);
break;
case 0:
m.invoke (this);
break;
default:
throw new RuntimeException ();
}
} catch (Throwable x) {
printException (x, true);
error (2);
}
outWriter.flush ();
errWriter.flush ();
}