Skip to content

Commit

Permalink
Console progress output on the same line
Browse files Browse the repository at this point in the history
  • Loading branch information
mrizzi authored and mareknovotny committed Apr 7, 2017
1 parent 409ad90 commit fe95b0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -56,7 +56,14 @@ public void setTaskName(String name)
public void subTask(String subTask)
{
String message = String.format("[%d/%d] %s", currentWork, totalWork, subTask);
System.out.println(message);
if (subTask.endsWith("\r"))
{
System.out.print(message);
}
else
{
System.out.println("\r" + message);
}
LOG.info(message);
}

Expand Down
Expand Up @@ -67,8 +67,12 @@ public boolean ruleEvaluationProgress(GraphRewrite event, String name, int curre
// don't redisplay it if nothing has changed
if (!newProgressMessage.equals(lastRuleProgressMessage))
{
if (lastRuleProgressMessage != null && lastRuleProgressMessage.length() > newProgressMessage.length())
{
newProgressMessage = String.format("%1$-" + lastRuleProgressMessage.length() + "s", newProgressMessage);
}
lastRuleProgressMessage = newProgressMessage;
progressMonitor.subTask(newProgressMessage);
progressMonitor.subTask(newProgressMessage + "\r");
}
return progressMonitor.isCancelled();
}
Expand Down

0 comments on commit fe95b0f

Please sign in to comment.