+ Added compare and info commands
This commit is contained in:
@@ -54,7 +54,7 @@ public class CommandShutdown extends Command
|
||||
}
|
||||
else
|
||||
{
|
||||
res.CallImmediate(LocStrings.Stub("ShutdownUnsafe"));// "`Shutting down and immediately and abandoning all threads without sync.`");
|
||||
res.CallImmediate(LocStrings.Stub("ShutdownUnsafe"));// "``");
|
||||
GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe"));
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package commands.benchmark;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import core.benchmark.BenchmarkCommand;
|
||||
import core.benchmark.BenchmarkEntry;
|
||||
import core.benchmark.BenchmarkInput;
|
||||
import core.benchmark.BenchmarkManager;
|
||||
|
||||
public class BenchmarkCommandCompare extends BenchmarkCommand
|
||||
{
|
||||
public String OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
final String lineDelimiter = "\n";
|
||||
String output = "";
|
||||
String[] inputSplit = input.value.trim().split("\\s+");
|
||||
|
||||
if(inputSplit.length < 2)
|
||||
return "You must to specify 2 models to compare!";
|
||||
|
||||
for(int i = 0; i < inputSplit.length; ++i)
|
||||
{
|
||||
if(i != 0)
|
||||
output += lineDelimiter;
|
||||
|
||||
List<BenchmarkEntry> entries = manager.FindModel(inputSplit[i]);
|
||||
|
||||
if(entries.size() < 1)
|
||||
output += "Couldn't find any models containing `" + inputSplit[i] + "`!";
|
||||
|
||||
output += BenchmarkCommandInfo.FormatInfo(entries.get(0));
|
||||
output += lineDelimiter;
|
||||
|
||||
if(entries.size() > 1)
|
||||
output += "_chose " + entries.get(0).model + " from " + entries.size() + " potential components. To see others, try the command `benchmark find " + inputSplit[i] +"`_)";
|
||||
|
||||
output += lineDelimiter;
|
||||
output += "----------";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import core.benchmark.*;
|
||||
|
||||
public class BenchmarkCommandFind extends BenchmarkCommand
|
||||
{
|
||||
final char lineDelimiter = '\n';
|
||||
private final char lineDelimiter = '\n';
|
||||
private final int listMax = 30;
|
||||
|
||||
public String OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
@@ -19,7 +20,6 @@ public class BenchmarkCommandFind extends BenchmarkCommand
|
||||
{
|
||||
output += "```" + lineDelimiter;
|
||||
int max = entries.size();
|
||||
final int listMax = 30;
|
||||
|
||||
boolean fencepost = true;
|
||||
for(int i = 0; i < entries.size() && i < listMax; ++i)
|
||||
@@ -33,7 +33,7 @@ public class BenchmarkCommandFind extends BenchmarkCommand
|
||||
}
|
||||
|
||||
if(max > listMax)
|
||||
output += "\n\nPlus " + (max - listMax) + " more items...";
|
||||
output += lineDelimiter + lineDelimiter + "Plus " + (max - listMax) + " more items...";
|
||||
|
||||
output += "```";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package commands.benchmark;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import core.benchmark.BenchmarkCommand;
|
||||
import core.benchmark.BenchmarkEntry;
|
||||
import core.benchmark.BenchmarkInput;
|
||||
import core.benchmark.BenchmarkManager;
|
||||
|
||||
public class BenchmarkCommandInfo extends BenchmarkCommand
|
||||
{
|
||||
static final String lineDelimiter = "\n";
|
||||
|
||||
public static String FormatInfo(BenchmarkEntry entry)
|
||||
{
|
||||
String output = "";
|
||||
|
||||
output += "`" + entry.brand + " " + entry.model + "`" + lineDelimiter;
|
||||
output += "<" + entry.url + ">";
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
String searchString = input.value.trim();
|
||||
|
||||
String output = "";
|
||||
output += lineDelimiter;
|
||||
|
||||
List<BenchmarkEntry> entries = manager.FindModel(searchString);
|
||||
|
||||
if(entries.size() < 1)
|
||||
output += "Couldn't find any models containing `" + searchString + "`!";
|
||||
|
||||
output += FormatInfo(entries.get(0));
|
||||
output += lineDelimiter;
|
||||
|
||||
if(entries.size() > 1)
|
||||
output += "_chose " + entries.get(0).model + " from " + entries.size() + " potential components. To see others, try the command `benchmark find " + searchString +"`_)";
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user