Skip to content

Commit

Permalink
refactor: minor refactor and semplification in tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Sep 11, 2023
1 parent b0eae15 commit b0e67b3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static com.orientechnologies.orient.core.config.OGlobalConfiguration.WARNING_DEFAULT_USERS;

import com.orientechnologies.common.collection.OMultiValue;
import com.orientechnologies.common.console.OConsoleApplication;
import com.orientechnologies.common.console.OConsoleProperties;
import com.orientechnologies.common.console.TTYConsoleReader;
import com.orientechnologies.common.console.annotation.ConsoleCommand;
Expand Down Expand Up @@ -120,8 +121,8 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class OConsoleDatabaseApp extends OrientConsole
implements OCommandOutputListener, OProgressListener {
public class OConsoleDatabaseApp extends OConsoleApplication
implements OCommandOutputListener, OProgressListener, OTableFormatter.OTableOutput {
protected ODatabaseDocumentInternal currentDatabase;
protected String currentDatabaseName;
protected ORecord currentRecord;
Expand Down Expand Up @@ -3282,7 +3283,7 @@ protected boolean isCollectingCommands(final String iLine) {

@Override
protected void onBefore() {
super.onBefore();
printApplicationInfo();

setResultset(new ArrayList<OIdentifiable>());

Expand Down Expand Up @@ -3589,4 +3590,39 @@ private Object sqlCommand(

return result;
}

@Override
public void onMessage(String text, Object... args) {
message(text, args);
}

@Override
protected void onException(Throwable e) {
Throwable current = e;
while (current != null) {
err.print("\nError: " + current.toString() + "\n");
current = current.getCause();
}
}

@Override
protected void onAfter() {
out.println();
}

protected String format(final String iValue, final int iMaxSize) {
if (iValue == null) return null;

if (iValue.length() > iMaxSize) return iValue.substring(0, iMaxSize - 3) + "...";
return iValue;
}

public boolean historyEnabled() {
for (String arg : args) {
if (arg.equalsIgnoreCase(PARAM_DISABLE_HISTORY)) {
return false;
}
}
return true;
}
}

This file was deleted.

0 comments on commit b0e67b3

Please sign in to comment.