Replaced field thinCliProtocol.dConsoleWriteLine with method Logger.Info()

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2022-05-06 11:23:56 +01:00
parent e31cfaeda5
commit c992c4b171
2 changed files with 12 additions and 11 deletions

View File

@ -39,7 +39,7 @@ namespace ThinCLI
public static void Main(string[] args) public static void Main(string[] args)
{ {
var tCliProtocol = new thinCLIProtocol( var tCliProtocol = new thinCLIProtocol(
Console.WriteLine, Console.ReadLine, Console.ReadLine,
Environment.Exit, i => { }, new Config()); Environment.Exit, i => { }, new Config());
string body = ""; string body = "";
@ -130,5 +130,10 @@ namespace ThinCLI
{ {
Console.WriteLine("Error: " + x); Console.WriteLine("Error: " + x);
} }
internal static void Info(string x)
{
Console.WriteLine(x);
}
} }
} }

View File

@ -52,14 +52,12 @@ namespace ThinCLI
public bool debug = false; public bool debug = false;
} }
public delegate void delegateConsoleWriteLine(String s);
public delegate string delegateConsoleReadLine(); public delegate string delegateConsoleReadLine();
public delegate void delegateExit(int i); public delegate void delegateExit(int i);
public delegate void delegateProgress(int i); public delegate void delegateProgress(int i);
public class thinCLIProtocol public class thinCLIProtocol
{ {
public delegateConsoleWriteLine dConsoleWriteLine;
public delegateConsoleReadLine dConsoleReadLine; public delegateConsoleReadLine dConsoleReadLine;
public delegateProgress dProgress; public delegateProgress dProgress;
public delegateExit dExit; public delegateExit dExit;
@ -71,13 +69,11 @@ namespace ThinCLI
public List<string> EnteredParamValues; public List<string> EnteredParamValues;
public thinCLIProtocol( public thinCLIProtocol(
delegateConsoleWriteLine dConsoleWriteLine,
delegateConsoleReadLine dConsoleReadLine, delegateConsoleReadLine dConsoleReadLine,
delegateExit dExit, delegateExit dExit,
delegateProgress dProgress, delegateProgress dProgress,
Config conf) Config conf)
{ {
this.dConsoleWriteLine = dConsoleWriteLine;
this.dConsoleReadLine = dConsoleReadLine; this.dConsoleReadLine = dConsoleReadLine;
this.dExit = dExit; this.dExit = dExit;
this.dProgress = dProgress; this.dProgress = dProgress;
@ -575,17 +571,17 @@ namespace ThinCLI
case Messages.tag.Print: case Messages.tag.Print:
msg = Types.unmarshal_string(stream); msg = Types.unmarshal_string(stream);
Logger.Debug("Read: Print: " + msg, tCLIprotocol); Logger.Debug("Read: Print: " + msg, tCLIprotocol);
tCLIprotocol.dConsoleWriteLine(msg); Logger.Info(msg);
break; break;
case Messages.tag.PrintStderr: case Messages.tag.PrintStderr:
msg = Types.unmarshal_string(stream); msg = Types.unmarshal_string(stream);
Logger.Debug("Read: PrintStderr: " + msg, tCLIprotocol); Logger.Debug("Read: PrintStderr: " + msg, tCLIprotocol);
tCLIprotocol.dConsoleWriteLine(msg); Logger.Info(msg);
break; break;
case Messages.tag.Debug: case Messages.tag.Debug:
msg = Types.unmarshal_string(stream); msg = Types.unmarshal_string(stream);
Logger.Debug("Read: Debug: " + msg, tCLIprotocol); Logger.Debug("Read: Debug: " + msg, tCLIprotocol);
tCLIprotocol.dConsoleWriteLine(msg); Logger.Info(msg);
break; break;
case Messages.tag.Exit: case Messages.tag.Exit:
int code = Types.unmarshal_int(stream); int code = Types.unmarshal_int(stream);
@ -595,7 +591,7 @@ namespace ThinCLI
case Messages.tag.Error: case Messages.tag.Error:
Logger.Debug("Read: Command Error", tCLIprotocol); Logger.Debug("Read: Command Error", tCLIprotocol);
string err_code = Types.unmarshal_string(stream); string err_code = Types.unmarshal_string(stream);
tCLIprotocol.dConsoleWriteLine("Error code: " + err_code); Logger.Info("Error code: " + err_code);
var paramList = new List<string>(); var paramList = new List<string>();
int length = Types.unmarshal_int(stream); int length = Types.unmarshal_int(stream);
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
@ -603,12 +599,12 @@ namespace ThinCLI
string param = Types.unmarshal_string(stream); string param = Types.unmarshal_string(stream);
paramList.Add(param); paramList.Add(param);
} }
tCLIprotocol.dConsoleWriteLine("Error params: " + string.Join(", ", paramList)); Logger.Info("Error params: " + string.Join(", ", paramList));
break; break;
case Messages.tag.Prompt: case Messages.tag.Prompt:
Logger.Debug("Read: Command Prompt", tCLIprotocol); Logger.Debug("Read: Command Prompt", tCLIprotocol);
string response = tCLIprotocol.dConsoleReadLine(); string response = tCLIprotocol.dConsoleReadLine();
tCLIprotocol.dConsoleWriteLine("Read "+response); Logger.Info("Read "+response);
/* NB, 4+4+4 here for the blob, chunk and string length, put in by the marshal_string /* NB, 4+4+4 here for the blob, chunk and string length, put in by the marshal_string
function. A franken-marshal. */ function. A franken-marshal. */
Types.marshal_int(stream, 4 + 4 + 4); // length Types.marshal_int(stream, 4 + 4 + 4); // length