From 99ba6e1710cd8edf449e422a14ab23a6a9bf3148 Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Thu, 2 Jan 2025 13:54:01 -0600 Subject: [PATCH] Release 1.2.0 --- Cogwheel.csproj | 8 +- src/COGWHEEL.cs | 102 +++++++++- src/CogwheelLib.csproj | 45 +++-- src/Command.cs | 22 ++- src/CommandAttribute.cs | 12 +- src/CommandsManager.cs | 295 +++++++++++++++++++++-------- src/DeafultCogwheelConsole.cs | 63 +++++- src/TestClass.cs | 20 -- src/changelog.md | 39 ++++ src/interfaces/ICogwheelConsole.cs | 51 ++++- src/interfaces/ICommand.cs | 14 ++ 11 files changed, 527 insertions(+), 144 deletions(-) delete mode 100644 src/TestClass.cs create mode 100644 src/changelog.md diff --git a/Cogwheel.csproj b/Cogwheel.csproj index b0a96e6..865efca 100644 --- a/Cogwheel.csproj +++ b/Cogwheel.csproj @@ -5,10 +5,14 @@ net9.0 enable enable + false + false - + + + - + \ No newline at end of file diff --git a/src/COGWHEEL.cs b/src/COGWHEEL.cs index 6e705b8..5b3de99 100644 --- a/src/COGWHEEL.cs +++ b/src/COGWHEEL.cs @@ -1,10 +1,18 @@ namespace Cogwheel; +/// +/// Static class for interacting with the Cogwheel system +/// public static class COGWHEEL { private static CommandsManager _commandsManager; private static ICogwheelConsole _console; + /// + /// Initializes the Cogwheel system + /// + /// + /// public static void Initialize(CommandsManager commandsManager, ICogwheelConsole console) { _console = console; @@ -16,11 +24,19 @@ public static class COGWHEEL // == Public static methods for the CommandsManager == // + /// + /// Runs a command + /// + /// public static void RunCommand(string input) { _commandsManager.RunCommand(input); } + /// + /// Registers an object with the CommandsManager for non-static commands + /// + /// public static void RegisterObject(object obj) { _commandsManager.RegisterObject(obj); @@ -28,43 +44,96 @@ public static class COGWHEEL // == Public static methods for the Console == // + /// + /// Logs a message to the console + /// + /// public static void Log(string message) { _console.Log(message); } + /// + /// Logs an error message to the console + /// + /// public static void LogError(string message) { _console.LogError(message); } + /// + /// Logs a warning message to the console + /// + /// public static void LogWarning(string message) { _console.LogWarning(message); } + /// + /// Writes a message to the console + /// + /// public static void Write(string message) { _console.Write(message); } + /// + /// Sets the context for the CommandsManager + /// + /// + public static void SetContext(object obj) + { + _commandsManager.SetContext(obj); + } + + /// + /// Sets the context for the CommandsManager by GUID + /// + /// + public static void SetContext(Guid guid) + { + _commandsManager.SetContext(guid); + } + + /// + /// Sets the context for the CommandsManager by GUID string + /// + /// + public static void SetContext(string guidString) + { + _commandsManager.SetContext(guidString); + } + // == Built-in commands == // + /// + /// Quit the Cogwheel console + /// [Command(Name = "quit", Description = "Quits the Cogwheel console.")] public static void QuitCogwheelConsole() { _console.Exit(); } + /// + /// Clears the console + /// [Command(Name = "clear", Description = "Clears the console.")] public static void ClearConsole() { _console.ClearConsole(); } + /// + /// Shows the description and usage of a given command + /// + /// [Command(Name = "help", Description = "Gets usage for given command.")] public static void ShowHelp(string commandName) { - ICommand command = _commandsManager.GetCommandByName(commandName); + ICommand? command = _commandsManager.GetCommandByName(commandName); if (command is null) { _console.LogError($"Command error: '{commandName}' is not a command."); @@ -76,6 +145,9 @@ public static class COGWHEEL $"Usage: {_commandsManager.GetCommandUsage(command)}"); } + /// + /// Lists all available commands + /// [Command(Name = "list", Description = "Lists all available commands.")] public static void ListCommands() { @@ -85,21 +157,27 @@ public static class COGWHEEL } } + /// + /// Logs the current context type and GUID + /// [Command(Name = "what", Description = "Prints the current context.")] public static void ShowCurrentContext() { + if (_commandsManager.CurrentContext is null) + { + Log("No context set."); + return; + } + _console.Log($"Current context: {_commandsManager.CurrentContext.GetType()} : {_commandsManager.CurrentContextGuid}"); } - [Command(Name = "test", Description = "Creates a new TestClass object.")] - public static void CreateTestObject(string name) - { - _console.Log($"Creating new TestClass object with name: {name}"); - var test = new TestClass(name); - } - + /// + /// Logs all registered objects and their GUIDs, optionally filtered by type + /// + /// [Command(Name = "find", Description = "Lists available registered objects to select from.")] - private static void SelectContextFromRegisteredObjects(string typeName = "") + private static void FindAllContextsFromRegisteredObjects(string typeName = "") { var registeredObjects = _commandsManager.RegisteredObjectInstances; var filteredObjects = string.IsNullOrEmpty(typeName) @@ -119,10 +197,14 @@ public static class COGWHEEL } } + /// + /// Sets the context to the specified registered object by GUID + /// + /// [Command(Name = "set", Description = "Sets the context to the specified registered object.")] private static void SetContextFromGuid(string guidString) { - _commandsManager.SetContext(guidString); + SetContext(guidString); Log($"Set context to {_commandsManager.CurrentContext?.GetType().FullName} : {_commandsManager.CurrentContextGuid}"); } } \ No newline at end of file diff --git a/src/CogwheelLib.csproj b/src/CogwheelLib.csproj index 0cd3deb..98389fb 100644 --- a/src/CogwheelLib.csproj +++ b/src/CogwheelLib.csproj @@ -1,24 +1,31 @@ - - Library - net9.0 - enable - enable - true - Cogwheel - 1.0.0 - Chris Bell - Bellsworne Tech - A suite of development tools for games - tools;gamedevelopment;debug - https://git.bellsworne.tech/Bellsworne/Cogwheel.git - false - + + Library + net9.0 + enable + enable + false + false + true + + + 1.2.0 + Chris Bell + Bellsworne Tech + A suite of development tools for games + development tools, games + https://git.bellsworne.tech/Bellsworne/Cogwheel/packages + https://git.bellsworne.tech/Bellsworne/Cogwheel.git + git + MIT + + - - - - + + + + + \ No newline at end of file diff --git a/src/Command.cs b/src/Command.cs index e0719d4..dfde387 100644 --- a/src/Command.cs +++ b/src/Command.cs @@ -2,12 +2,32 @@ using System.Reflection; namespace Cogwheel; +/// +/// Represents a command in the Cogwheel system. +/// public class Command : ICommand { + /// + /// Gets the name of the command. + /// public string Name { get; } + + /// + /// Gets the description of the command. + /// public string Description { get; } + + /// + /// Gets the method associated with the command. + /// public MethodBase Method { get; } - + + /// + /// Initializes a new instance of the class. + /// + /// The name of the command. + /// The description of the command. + /// The method associated with the command. public Command(string name, string description, MethodBase method) { Name = name; diff --git a/src/CommandAttribute.cs b/src/CommandAttribute.cs index b2ea52f..b3d98c1 100644 --- a/src/CommandAttribute.cs +++ b/src/CommandAttribute.cs @@ -1,8 +1,18 @@ namespace Cogwheel; +/// +/// Attribute for marking methods as commands +/// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class CommandAttribute : Attribute { - public string Name = ""; + /// + /// Optional name of the command, if not provided the method name will be used + /// + public string? Name = ""; + + /// + /// Optional description of the command + /// public string Description = ""; } \ No newline at end of file diff --git a/src/CommandsManager.cs b/src/CommandsManager.cs index b75bef3..c53a954 100644 --- a/src/CommandsManager.cs +++ b/src/CommandsManager.cs @@ -2,33 +2,75 @@ using System.Reflection; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; -using Exception = System.Exception; namespace Cogwheel; +/// +/// Manages commands for the Cogwheel system. +/// public class CommandsManager { + /// + /// Gets or sets the console used by the CommandsManager. + /// protected virtual ICogwheelConsole CogwheelConsole { get; set; } + + /// + /// Gets or sets the pattern used to parse commands. + /// protected virtual string CommandPattern { get; set; } = "(?(\\([^\\)]+\\)))|\"(?[^\"]+)\"|'(?[^']+)'|(?[^\\s]+)"; - - protected virtual List Assemblies { get; set; } = []; + + /// + /// Gets or sets the list of assemblies to search for commands. + /// + protected virtual List Assemblies { get; set; } = new(); + + /// + /// Gets or sets the dictionary of commands. + /// public virtual Dictionary Commands { get; set; } = new(); + + /// + /// Gets or sets the dictionary of custom parsers for command parameters. + /// public virtual Dictionary> CustomParsers { get; set; } = new(); - - // Context related stuff + + /// + /// Gets or sets the current context object. + /// public virtual object? CurrentContext { get; set; } + + /// + /// Gets or sets the GUID of the current context. + /// public virtual Guid? CurrentContextGuid { get; set; } + + /// + /// Gets or sets the dictionary of registered object instances. + /// public virtual Dictionary RegisteredObjectInstances { get; set; } = new(); + + /// + /// Gets or sets the dictionary of registered object GUIDs. + /// public virtual Dictionary RegisteredObjectGuids { get; set; } = new(); - + + /// + /// Initializes the CommandsManager with the specified console. + /// + /// The console to use. public virtual void Initialize(ICogwheelConsole console) { CogwheelConsole = console; RefreshCommandsList(); CogwheelConsole.Log($"CommandsManager initialized, Commands found: {Commands.Count}"); } - - + + /// + /// Gets the command and arguments from the input string. + /// + /// The input string. + /// A tuple containing the command and arguments, or null if the command is not found. public virtual (ICommand, List)? GetCommandAndArgsFromString(string input) { var splitString = Regex.Matches(input, CommandPattern).Select(m => m.Groups["val"].Value).ToArray(); @@ -38,7 +80,7 @@ public class CommandsManager { args.Add(splitString[splitIndex]); } - + if (Commands.TryGetValue(commandName, out var command)) { return (command, args); @@ -47,6 +89,12 @@ public class CommandsManager return null; } + /// + /// Runs the command specified by the input string. + /// + /// The input string. + /// The context object, if any. + /// True if the command was executed successfully, otherwise false. public virtual bool RunCommand(string input, object? context = null) { if (string.IsNullOrWhiteSpace(input)) return false; @@ -72,11 +120,18 @@ public class CommandsManager return ExecuteCommand(CurrentContext, command.Value); } - //CogwheelConsole.LogWarning($"Command '{command.Value.Item1.Name}' is not static and no valid context was provided, searching for first registered context of type '{command.Value.Item1.Method.DeclaringType}'"); - context = GetFirstValidRegisteredContext(command.Value.Item1.Method.DeclaringType); - if (context is null) + if (command.Value.Item1.Method.DeclaringType != null) { - CogwheelConsole.LogError($"No context of type '{command.Value.Item1.Method.DeclaringType}' found"); + context = GetFirstValidRegisteredContext(command.Value.Item1.Method.DeclaringType); + if (context is null) + { + CogwheelConsole.LogError($"No context of type '{command.Value.Item1.Method.DeclaringType}' found"); + return false; + } + } + else + { + CogwheelConsole.LogError($"Command '{command.Value.Item1.Name}' has no declaring type"); return false; } @@ -88,6 +143,11 @@ public class CommandsManager return false; } + /// + /// Gets the usage information for the specified command. + /// + /// The command. + /// The usage information for the command. public virtual string GetCommandUsage(ICommand command) { string output = ""; @@ -99,18 +159,18 @@ public class CommandsManager { output += "|Global| "; } - + output += $"{command.Name}: "; - + if (!string.IsNullOrWhiteSpace(command.Description)) { output += $"{command.Description} "; } - + string paramUsage = string.Join(" ", command.Method.GetParameters().Select(param => $"<{(param.IsDefined(typeof(ParamArrayAttribute)) ? "params " : "")}{param}>")); - + if (!string.IsNullOrWhiteSpace(paramUsage)) { output += $"- {paramUsage}"; @@ -119,49 +179,26 @@ public class CommandsManager return output; } - public virtual bool ExecuteCommand(object obj, (ICommand command, List args) command) + /// + /// Executes the specified command with the given arguments. + /// + /// The object on which to execute the command. + /// The command and arguments. + /// True if the command was executed successfully, otherwise false. + public virtual bool ExecuteCommand(object? obj, (ICommand command, List args) command) { var parameters = command.command.Method.GetParameters(); - for (var parameterIndex = 0; parameterIndex < parameters.Length; parameterIndex++) + for (var parameterIndex = 0; parameterIndex < parameters.Length; parameterIndex++) + { + if (parameters[parameterIndex].IsDefined(typeof(ParamArrayAttribute), false)) { - if (parameters[parameterIndex].IsDefined(typeof(ParamArrayAttribute), false)) + var paramList = Activator.CreateInstance(typeof(List<>).MakeGenericType(parameters[parameterIndex].ParameterType.GetElementType()!)); + for (var argIndex = parameterIndex; argIndex < parameters.Length; argIndex++) { - var paramList = Activator.CreateInstance(typeof(List<>).MakeGenericType(parameters[parameterIndex].ParameterType.GetElementType()!)); - for (var argIndex = parameterIndex; argIndex < parameters.Length; argIndex++) + if (TryParseParameter(parameters[parameterIndex].ParameterType.GetElementType(), + (string)command.args[argIndex], out var val)) { - if (TryParseParameter(parameters[parameterIndex].ParameterType.GetElementType(), - (string)command.args[argIndex], out var val)) - { - paramList.GetType().GetMethod("Add")?.Invoke(paramList, new[] { val }); - } - else - { - CogwheelConsole.LogError($"Format exception: could not parse '{command.args[parameterIndex]}' as '{parameters[parameterIndex].ParameterType}'"); - return false; - } - } - - command.args = command.args.Take(parameterIndex).ToList(); - command.args.Add(paramList.GetType().GetMethod("ToArray")?.Invoke(paramList, null)); - } - else if (parameterIndex >= command.args.Count) - { - if (parameters[parameterIndex].IsOptional) - { - command.args.Add(Type.Missing); - } - else - { - CogwheelConsole.LogError("Not enough args passed"); - CogwheelConsole.Log(GetCommandUsage(command.command)); - return false; - } - } - else - { - if (TryParseParameter(parameters[parameterIndex].ParameterType, (string)command.args[parameterIndex], out var val)) - { - command.args[parameterIndex] = val; + paramList.GetType().GetMethod("Add")?.Invoke(paramList, [val]); } else { @@ -169,21 +206,56 @@ public class CommandsManager return false; } } - } - try - { - command.command.Method.Invoke(obj, command.args.ToArray()); - return true; + command.args = command.args.Take(parameterIndex).ToList(); + command.args.Add(paramList.GetType().GetMethod("ToArray")?.Invoke(paramList, null)); } - catch (Exception e) + else if (parameterIndex >= command.args.Count) { - CogwheelConsole.LogError(e.Message); - throw; + if (parameters[parameterIndex].IsOptional) + { + command.args.Add(Type.Missing); + } + else + { + CogwheelConsole.LogError($"Not enough args passed. Usage: {GetCommandUsage(command.command)}"); + return false; + } } + else + { + if (TryParseParameter(parameters[parameterIndex].ParameterType, (string)command.args[parameterIndex], out var val)) + { + command.args[parameterIndex] = val; + } + else + { + CogwheelConsole.LogError($"Format exception: could not parse '{command.args[parameterIndex]}' as '{parameters[parameterIndex].ParameterType}'"); + return false; + } + } + } + + try + { + command.command.Method.Invoke(obj, command.args.ToArray()); + return true; + } + catch (Exception e) + { + CogwheelConsole.LogError(e.Message); + throw; + } } - public virtual bool TryParseParameter(Type parameterType, string parameterString, out object parsedValue) + /// + /// Tries to parse the parameter string into the specified parameter type. + /// + /// The type of the parameter. + /// The parameter string. + /// The parsed value. + /// True if the parameter was parsed successfully, otherwise false. + public virtual bool TryParseParameter(Type parameterType, string parameterString, out object? parsedValue) { if (parameterType == typeof(string)) { @@ -224,21 +296,27 @@ public class CommandsManager } } } - + parsedValue = null; return false; } + /// + /// Gets the command by its name. + /// + /// The name of the command. + /// The command, or null if not found. public virtual ICommand? GetCommandByName(string commandName) { return Commands.GetValueOrDefault(commandName); } - // Context related stuff - + /// + /// Registers the specified object with the CommandsManager. + /// + /// The object to register. public virtual void RegisterObject(object obj) { - // Use a combination of the object's type and a hash of its properties to generate a deterministic GUID string seed = obj.GetType().FullName + GetObjectPropertiesHash(obj); using (MD5 md5 = MD5.Create()) { @@ -257,7 +335,13 @@ public class CommandsManager } } } - + + /// + /// Checks if the command context is valid. + /// + /// The command. + /// The context object, if any. + /// True if the context is valid, otherwise false. public virtual bool IsCommandContextValid(ICommand command, object? context = null) { if (context is not null) @@ -267,6 +351,11 @@ public class CommandsManager return command.Method.DeclaringType == CurrentContext?.GetType(); } + /// + /// Sets the current context to the specified object. + /// + /// The context object. + /// True if the context was set successfully, otherwise false. public virtual bool SetContext(object context) { CurrentContext = context; @@ -279,6 +368,11 @@ public class CommandsManager return true; } + /// + /// Sets the current context to the object with the specified GUID. + /// + /// The GUID of the context object. + /// True if the context was set successfully, otherwise false. public virtual bool SetContext(Guid guid) { if (RegisteredObjectInstances.ContainsKey(guid)) @@ -295,6 +389,11 @@ public class CommandsManager return true; } + /// + /// Sets the current context to the object with the specified GUID string. + /// + /// The GUID string of the context object. + /// True if the context was set successfully, otherwise false. public virtual bool SetContext(string guidString) { if (Guid.TryParse(guidString, out var guid)) @@ -306,21 +405,53 @@ public class CommandsManager return false; } + /// + /// Gets the first valid registered context of the specified type. + /// + /// The type of the context. + /// The first valid registered context, or null if not found. public virtual object? GetFirstValidRegisteredContext(Type type) { return RegisteredObjectInstances.Values.FirstOrDefault(obj => obj.GetType() == type); } + /// + /// Gets the GUID of the specified context object. + /// + /// The context object, if any. + /// The GUID of the context object. public virtual Guid GetGuidFromContext(object? context = null) { if (context is not null) { return RegisteredObjectGuids[context]; } - + return CurrentContextGuid ?? Guid.Empty; } + /// + /// Adds the specified assembly to the list of assemblies to search for commands. + /// + /// + public void AddAssembly(Assembly assembly) + { + if (!Assemblies.Contains(assembly)) + { + Assemblies.Add(assembly); + RefreshCommandsList(); + } + else + { + CogwheelConsole.LogWarning($"Tried to add {assembly.FullName} but it is already registered."); + } + } + + /// + /// Gets the hash of the properties of the specified object. + /// + /// The object. + /// The hash of the object's properties. protected virtual string GetObjectPropertiesHash(object obj) { var properties = obj.GetType().GetProperties(); @@ -335,21 +466,27 @@ public class CommandsManager return sb.ToString(); } + /// + /// Refreshes the list of commands by scanning the assemblies. + /// protected virtual void RefreshCommandsList() { - foreach (var type in Assembly.GetCallingAssembly().GetTypes()) + foreach (var assembly in Assemblies) { - var methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance); - - foreach (var method in methods) + foreach (var type in assembly.GetTypes()) { - var attributes = method.GetCustomAttributes(); + var methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance); - foreach (var attribute in attributes) + foreach (var method in methods) { - var commandName = attribute.Name ?? method.Name; - var newCommand = new Command(commandName, attribute.Description, method); - Commands.TryAdd(newCommand.Name, newCommand); + var attributes = method.GetCustomAttributes(); + + foreach (var attribute in attributes) + { + var commandName = attribute.Name ?? method.Name; + var newCommand = new Command(commandName, attribute.Description, method); + Commands.TryAdd(newCommand.Name, newCommand); + } } } } diff --git a/src/DeafultCogwheelConsole.cs b/src/DeafultCogwheelConsole.cs index c65cf0f..0c38e6e 100644 --- a/src/DeafultCogwheelConsole.cs +++ b/src/DeafultCogwheelConsole.cs @@ -1,60 +1,105 @@ namespace Cogwheel; using System; -using System.Collections.Generic; -using System.Linq; +/// +/// Default implementation of the Cogwheel console. +/// public class DeafultCogwheelConsole : ICogwheelConsole { + /// + /// Gets or sets the opening message of the console. + /// public string OpeningMessage { get; set; } = "** COGWHEEL CONSOLE **"; + + /// + /// Gets or sets a value indicating whether the console is running. + /// public bool IsRunning { get; set; } + + /// + /// Gets or sets the commands manager associated with the console. + /// public CommandsManager CommandsManager { get; set; } - - + + /// + /// Initializes the console with the specified commands manager. + /// + /// The commands manager to use. public void Initialize(CommandsManager commandsManager) { CommandsManager = commandsManager; CommandsManager.RegisterObject(this); - + Write(OpeningMessage); - + IsRunning = true; while (IsRunning) { - Console.Write("> "); + if (CommandsManager.CurrentContext != null) + { + Console.Write($"({CommandsManager.CurrentContext.GetType().FullName})> "); + } + else + { + Console.Write("(Global)> "); + } string input = Console.ReadLine(); + Console.WriteLine(); CommandsManager.RunCommand(input); + Console.WriteLine(); } } + /// + /// Logs a message to the console. + /// + /// The message to log. public void Log(string message) { Console.WriteLine($"[COGWHEEL] {message}"); } + /// + /// Logs an error message to the console. + /// + /// The error message to log. public void LogError(string message) { Console.WriteLine($"[COGWHEEL ERROR] {message}"); } + /// + /// Logs a warning message to the console. + /// + /// The warning message to log. public void LogWarning(string message) { Console.WriteLine($"[COGWHEEL WARNING] {message}"); } - + + /// + /// Writes a message to the console. + /// + /// The message to write. public void Write(string message) { Console.WriteLine(message); } + /// + /// Clears the console. + /// public void ClearConsole() { Console.Clear(); } + /// + /// Exits the console. + /// public void Exit() { IsRunning = false; } - } \ No newline at end of file diff --git a/src/TestClass.cs b/src/TestClass.cs deleted file mode 100644 index 1add217..0000000 --- a/src/TestClass.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Cogwheel; - -public class TestClass -{ - - public string Name { get; set; } = "Test"; - - public TestClass(string name) - { - Name = name; - - COGWHEEL.RegisterObject(this); - } - - [Command(Name = "getname", Description = "Prints the name of the TestClass instance.")] - private void GetName() - { - COGWHEEL.Log($"My name is {Name}"); - } -} \ No newline at end of file diff --git a/src/changelog.md b/src/changelog.md new file mode 100644 index 0000000..5618a9f --- /dev/null +++ b/src/changelog.md @@ -0,0 +1,39 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.2.0] - 2025-01-02 + +### Added +- v1.1.1 - Ability to add assemblies to the CommandManager + +### Changed + +### Fixed + +### Removed + + +## [1.1.0] - 2025-01-02 + +### Added + +### Changed + +### Fixed + +### Removed + + +## [1.0.0] - 2025-01-02 + +### Added + +### Changed + +### Fixed + +### Removed \ No newline at end of file diff --git a/src/interfaces/ICogwheelConsole.cs b/src/interfaces/ICogwheelConsole.cs index ee5fb6e..8e8119e 100644 --- a/src/interfaces/ICogwheelConsole.cs +++ b/src/interfaces/ICogwheelConsole.cs @@ -1,17 +1,62 @@ namespace Cogwheel; +/// +/// Interface for the Cogwheel console. +/// public interface ICogwheelConsole { + /// + /// Gets or sets the opening message of the console. + /// public string OpeningMessage { get; set; } + + /// + /// Gets or sets a value indicating whether the console is running. + /// public bool IsRunning { get; set; } + + /// + /// Gets or sets the commands manager associated with the console. + /// public CommandsManager CommandsManager { get; set; } - - public void Initialize(CommandsManager commandsManager); // Make sure to pass the CommandsManager instance to the Console + + /// + /// Initializes the console with the specified commands manager. + /// + /// The commands manager to use. + public void Initialize(CommandsManager commandsManager); + + /// + /// Logs a message to the console. + /// + /// The message to log. public void Log(string message); + + /// + /// Logs an error message to the console. + /// + /// The error message to log. public void LogError(string message); + + /// + /// Logs a warning message to the console. + /// + /// The warning message to log. public void LogWarning(string message); + + /// + /// Writes a message to the console. + /// + /// The message to write. public void Write(string message); + + /// + /// Clears the console. + /// public void ClearConsole(); + + /// + /// Exits the console. + /// public void Exit(); - } \ No newline at end of file diff --git a/src/interfaces/ICommand.cs b/src/interfaces/ICommand.cs index 9dc10fa..c55add3 100644 --- a/src/interfaces/ICommand.cs +++ b/src/interfaces/ICommand.cs @@ -2,9 +2,23 @@ using System.Reflection; namespace Cogwheel; +/// +/// Represents a command in the Cogwheel system. +/// public interface ICommand { + /// + /// Gets the name of the command. + /// public string Name { get; } + + /// + /// Gets the description of the command. + /// public string Description { get; } + + /// + /// Gets the method associated with the command. + /// public MethodBase Method { get; } } \ No newline at end of file