diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 87bd24a..79c6349 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -34,12 +34,26 @@ using static ShiftOS.Engine.SaveSystem; namespace ShiftOS.Engine { + /// + /// Backend for the ShiftOS terminal. + /// public static class TerminalBackend { + /// + /// Occurs when a command is processed. + /// public static event Action CommandProcessed; + /// + /// Gets or sets whether the current command is elevated. + /// public static bool Elevated { get; set; } + /// + /// Parses command-line arguments using the ShiftOS syntax and stores them in a , removing the parsed text from the original string. + /// + /// The text to parse. + /// containing the parsed arguments. public static Dictionary GetArgs(ref string text) { bool shouldParse = false; @@ -64,8 +78,18 @@ namespace ShiftOS.Engine return JsonConvert.DeserializeObject>(args); } + /// + /// String representing the last command entered by the user. + /// public static string LastCommand = ""; + /// + /// Invokes a ShiftOS terminal command. + /// + /// The command's namespace. + /// The command name. + /// The command arguments. + /// Whether the command should be sent through Remote Terminal Session (RTS). public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) { try @@ -97,6 +121,11 @@ namespace ShiftOS.Engine } } + /// + /// Transforms a of arguments to a . + /// + /// The original argument dictionary to convert. + /// The converted dictionary. public static string GetSentArgs(Dictionary argss) { Dictionary args = new Dictionary(); @@ -107,6 +136,11 @@ namespace ShiftOS.Engine return JsonConvert.SerializeObject(args); } + /// + /// Invokes a ShiftOS terminal command. + /// + /// The full command text in regular ShiftOS syntax + /// Whether the command should be sent through Remote Terminal Session (RTS). public static void InvokeCommand(string text, bool isRemote = false) { try @@ -138,19 +172,40 @@ namespace ShiftOS.Engine } } + /// + /// Gets or sets whether the user prefix is printed after a command completes. + /// public static bool PrefixEnabled { get; set; } + /// + /// Gets or sets whether the user is in a story plot, and thus, the terminal input should be disabled. + /// public static bool InStory { get; set; } + /// + /// Another latest command string. + /// public static string latestCommmand = ""; + /// + /// Occurs when the engine requests a Terminal to be open. + /// public static event EmptyEventHandler TerminalRequested; + /// + /// Opens a Terminal. + /// internal static void OpenTerminal() { TerminalRequested?.Invoke(); } + /// + /// Determines if the specified command method can be ran in RTS + /// + /// The method to scan + /// Is the user in an RTS session? + /// Whether the command can be run. public static bool CanRunRemotely(MethodInfo mth, bool isRemote) { if (!isRemote) @@ -165,12 +220,26 @@ namespace ShiftOS.Engine return true; } + /// + /// Runs a command on the client-side. + /// + /// The command's namespace. + /// The command name. + /// The command's arguments. + /// Whether the command should be ran through RTS. + /// Whether the command ran successfully. public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) { return RunClient(ns + "." + cmd, args, isRemote); } - + /// + /// Runs a command on the client. + /// + /// The command text. + /// The command arguments. + /// Whether the command should be ran through RTS. + /// Whether the command ran successfully. public static bool RunClient(string text, Dictionary argss, bool isRemote = false) { Dictionary args = new Dictionary(); @@ -181,6 +250,13 @@ namespace ShiftOS.Engine return RunClient(text, args, isRemote); } + /// + /// Runs a command on the client. + /// + /// The command text. + /// The command arguments. + /// Whether the command should be run in RTS. + /// Whether the command ran successfully. public static bool RunClient(string text, Dictionary args, bool isRemote = false) { latestCommmand = text; @@ -420,6 +496,9 @@ namespace ShiftOS.Engine return false; } + /// + /// Prints the user prompt to the terminal. + /// public static void PrintPrompt() { if (SaveSystem.CurrentSave != null && CurrentUser != null) @@ -459,7 +538,9 @@ namespace ShiftOS.Engine } } - + /// + /// Static constructor for . + /// static TerminalBackend() { ServerMessageReceived onMessageReceived = (msg) => @@ -514,11 +595,25 @@ namespace ShiftOS.Engine ServerManager.MessageReceived += onMessageReceived; } + /// + /// Gets whether the terminal backend is forwarding console write requests through RTS to a remote client. + /// public static bool IsForwardingConsoleWrites { get; internal set; } + + /// + /// Gets the RTS forward GUID. + /// public static string ForwardGUID { get; internal set; } + /// + /// Occurs when the user inputs text in a Terminal. + /// public static event TextSentEventHandler TextSent; + /// + /// Fakes the user inputting text to a Terminal. + /// + /// The text to input. public static void SendText(string text) { TextSent?.Invoke(text);