|
|
@@ -24,18 +24,20 @@ namespace ExtraCommands.Basics |
|
|
|
public override void Ready() |
|
|
|
{ |
|
|
|
uREPL.RuntimeCommands.Register<string, string>("Chain", ChainCommand, "Run two commands, one after the other"); |
|
|
|
uREPL.RuntimeCommands.Register<string, string>("ChainNoFail", ChainCommand, "Run two commands, one after the other even if the first one is invalid"); |
|
|
|
uREPL.RuntimeCommands.Register<string, string>("ChainQuiet", ChainCommand, "Run two commands, one after the other quietly"); |
|
|
|
uREPL.RuntimeCommands.Register<string, string>("ChainNoFail", ChainNoFailCommand, "Run two commands, one after the other even if the first one is invalid"); |
|
|
|
uREPL.RuntimeCommands.Register<string, string>("ChainQuiet", ChainQuietCommand, "Run two commands, one after the other quietly"); |
|
|
|
} |
|
|
|
|
|
|
|
private void ChainCommand(string command1, string command2) |
|
|
|
{ |
|
|
|
bool success1 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1); |
|
|
|
string command1a = decomma(command1); |
|
|
|
string command2a = decomma(command2); |
|
|
|
bool success1 = uREPL.Evaluator.Evaluate(command1a).type == CompileResult.Type.Success; |
|
|
|
if (!success1) { |
|
|
|
uREPL.Log.Error("First command was not executed successfully"); |
|
|
|
return; |
|
|
|
} |
|
|
|
bool success2 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2); |
|
|
|
bool success2 = uREPL.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success; |
|
|
|
if (!success2) { |
|
|
|
uREPL.Log.Error("Second command was not executed successfully"); |
|
|
|
} |
|
|
@@ -43,11 +45,13 @@ namespace ExtraCommands.Basics |
|
|
|
|
|
|
|
private void ChainNoFailCommand(string command1, string command2) |
|
|
|
{ |
|
|
|
bool success1 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1); |
|
|
|
string command1a = decomma(command1); |
|
|
|
string command2a = decomma(command2); |
|
|
|
bool success1 = uREPL.Evaluator.Evaluate(command1a).type == CompileResult.Type.Success; |
|
|
|
if (!success1) { |
|
|
|
uREPL.Log.Error("First command was not executed successfully"); |
|
|
|
} |
|
|
|
bool success2 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2); |
|
|
|
bool success2 = uREPL.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success; |
|
|
|
if (!success2) { |
|
|
|
uREPL.Log.Error("Second command was not executed successfully"); |
|
|
|
} |
|
|
@@ -55,8 +59,33 @@ namespace ExtraCommands.Basics |
|
|
|
|
|
|
|
private void ChainQuietCommand(string command1, string command2) |
|
|
|
{ |
|
|
|
uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1); |
|
|
|
uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2); |
|
|
|
string command1a = decomma(command1); |
|
|
|
string command2a = decomma(command2); |
|
|
|
uREPL.Evaluator.Evaluate(command1a); |
|
|
|
uREPL.Evaluator.Evaluate(command2a); |
|
|
|
} |
|
|
|
|
|
|
|
private string decomma(string strIn) |
|
|
|
{ |
|
|
|
string strOut = ""; |
|
|
|
bool wasCommaLast = false; |
|
|
|
foreach (char c in strIn) |
|
|
|
{ |
|
|
|
if (wasCommaLast) |
|
|
|
{ |
|
|
|
wasCommaLast = false; |
|
|
|
if (c == ' ') |
|
|
|
{ |
|
|
|
strOut = strOut.Substring(0, strOut.Length - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (c == ',') |
|
|
|
{ |
|
|
|
wasCommaLast = true; |
|
|
|
} |
|
|
|
strOut += c; |
|
|
|
} |
|
|
|
return strOut; |
|
|
|
} |
|
|
|
|
|
|
|
public override void Dispose() |
|
|
|