diff --git a/Console.Waterworks/CW_Console/ConsoleCommands.cs b/Console.Waterworks/CW_Console/ConsoleCommands.cs index 77b6171..126098f 100644 --- a/Console.Waterworks/CW_Console/ConsoleCommands.cs +++ b/Console.Waterworks/CW_Console/ConsoleCommands.cs @@ -43,7 +43,7 @@ namespace CW_Console [ListCommand()] [Description("Take the int and double and adds them together.")] [Parameters(" int1, double1")] - [Usage("CW_Console> 31 25.4")] + [Usage("CW_Console> Command5 31 25.4")] public static string Command5(int int1, double double1) => $"Command5 has completed... {int1} and {double1} was entered and make {int1 + double1} when added together"; [ListCommand()] diff --git a/Console.Waterworks/Console.Waterworks/Assistants/CoOrdinatorAssistant.cs b/Console.Waterworks/Console.Waterworks/Assistants/CoOrdinatorAssistant.cs index 398e6a1..2f661cb 100644 --- a/Console.Waterworks/Console.Waterworks/Assistants/CoOrdinatorAssistant.cs +++ b/Console.Waterworks/Console.Waterworks/Assistants/CoOrdinatorAssistant.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; +using Console.Waterworks.Constants; using Console.Waterworks.Loggers; using Console.Waterworks.Specialists; +using System; +using System.Collections.Generic; using System.Reflection; -using Console.Waterworks.Constants; namespace Console.Waterworks.Assistants { diff --git a/Console.Waterworks/Console.Waterworks/CW_Liaison.cs b/Console.Waterworks/Console.Waterworks/CW_Liaison.cs index bcf5b12..46a200d 100644 --- a/Console.Waterworks/Console.Waterworks/CW_Liaison.cs +++ b/Console.Waterworks/Console.Waterworks/CW_Liaison.cs @@ -1,23 +1,32 @@ using Console.Waterworks.CoOrdinators; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Console.Waterworks { public class CW_Liaison { - CoOrdinator kevin = new CoOrdinator(); + CoOrdinator _kevin = new CoOrdinator(); + /// + /// Hands control over to Console.Waterworks so the program can "run" as intended. + /// + /// The place where the program's command-methods are. + /// Information about the console program, stated in Assembly Information. public void Run(string consoleCommandsNamespace,bool includeProgramInfo) { - kevin.PrepareConsoleEnvironment(); - if (includeProgramInfo == true) kevin.DisplayProgramInfo(); - kevin.RunProgram(consoleCommandsNamespace); + _kevin.PrepareConsoleEnvironment(); + if (includeProgramInfo == true) _kevin.DisplayProgramInfo(); + _kevin.RunProgram(consoleCommandsNamespace); } - public string RequestHelpDocumentation(string consoleCommandsNamespace) => kevin.DisplayHelpSection(consoleCommandsNamespace); + /// + /// Displays all the attribute information it can find, attached to the command-methods, at run-time. + /// + /// + /// The returned string does not include the "help" information. + /// It returns a string to indicate the method has finished collating the attribute information and displaying the information in the console. + /// This method is intended to be use in a command-method. So, it aims to be compatible with command-method behaviour + /// + /// The location of the programs command-method. + public string RequestHelpDocumentation(string consoleCommandsNamespace) => _kevin.DisplayHelpSection(consoleCommandsNamespace); } } diff --git a/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs b/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs index 78f0ef4..3c74d79 100644 --- a/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs +++ b/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs @@ -9,87 +9,87 @@ namespace Console.Waterworks.CoOrdinators { class CoOrdinator { - CoOrdinatorAssistant Assistant = new CoOrdinatorAssistant(); - ProgramInfoSpecialist ProgInfoSpec = new ProgramInfoSpecialist(); - ConsoleIOSpecialist ConsoleSpec = new ConsoleIOSpecialist(); - CommandsSpecialist CommSpec = new CommandsSpecialist(); - HelpSpecialist HelpSpec = new HelpSpecialist(); - CW_Logger Logger = new CW_Logger(); + CoOrdinatorAssistant _assistant = new CoOrdinatorAssistant(); + ProgramInfoSpecialist _progInfoSpec = new ProgramInfoSpecialist(); + ConsoleIOSpecialist _consoleSpec = new ConsoleIOSpecialist(); + CommandsSpecialist _commSpec = new CommandsSpecialist(); + HelpSpecialist _helpSpec = new HelpSpecialist(); + CW_Logger _logger = new CW_Logger(); internal void PrepareConsoleEnvironment() { - Logger.LogInfoMessage($"Preparing console.."); - ConsoleSpec.PrepareConsoleEnvironment(); - ConsoleSpec.SetInputPrompt($"{ProgInfoSpec.GetProductName()}> "); - Logger.LogSuccessMessage("Console environment is now setup"); + _logger.LogInfoMessage($"Preparing console.."); + _consoleSpec.PrepareConsoleEnvironment(); + _consoleSpec.SetInputPrompt($"{_progInfoSpec.GetProductName()}> "); + _logger.LogSuccessMessage("Console environment is now setup"); } internal void DisplayProgramInfo() { - Logger.LogInfoMessage($"Displaying program information.."); - Assistant.SetConsoleTitle(Logger, ProgInfoSpec, ConsoleSpec); - Assistant.OutputProgramInfo(Logger, ProgInfoSpec, ConsoleSpec); + _logger.LogInfoMessage($"Displaying program information.."); + _assistant.SetConsoleTitle(_logger, _progInfoSpec, _consoleSpec); + _assistant.OutputProgramInfo(_logger, _progInfoSpec, _consoleSpec); } internal void RunProgram(string commandsNamespace) { - Logger.LogInfoMessage("Attempting to building commands library.."); - var commandClasses = CommSpec.GetCommandClasses(commandsNamespace); - var commandLibraries = CommSpec.GetCommandLibraries(commandClasses); - Assistant.LogCommandGatheringAttempt(commandClasses, commandLibraries, Logger); + _logger.LogInfoMessage("Attempting to building commands library.."); + var commandClasses = _commSpec.GetCommandClasses(commandsNamespace); + var commandLibraries = _commSpec.GetCommandLibraries(commandClasses); + _assistant.LogCommandGatheringAttempt(commandClasses, commandLibraries, _logger); while (true) { - var consoleInput = ConsoleSpec.GetInputFromUser(); + var consoleInput = _consoleSpec.GetInputFromUser(); if (string.IsNullOrEmpty(consoleInput)) continue; try { - Logger.LogInfoMessage("Parsing input from user.."); + _logger.LogInfoMessage("Parsing input from user.."); var command = new Command(consoleInput, commandsNamespace, CW_Constants.COMMAND_CLASS_NAME); - Logger.LogInfoMessage("Attempting to execute command.."); - var result = CommSpec.ExecuteCommand(commandsNamespace, command, commandClasses, commandLibraries, ConsoleSpec); - ConsoleSpec.WriteOutputToConsole(result); - Logger.LogSuccessMessage("Command has been executed."); - Logger.LogNoteMessage("An error message does not mean the command did not execute properly or sucessfully."); + _logger.LogInfoMessage("Attempting to execute command.."); + var result = _commSpec.ExecuteCommand(commandsNamespace, command, commandClasses, commandLibraries, _consoleSpec); + _consoleSpec.WriteOutputToConsole(result); + _logger.LogSuccessMessage("Command has been executed."); + _logger.LogNoteMessage("An error message does not mean the command did not execute properly or sucessfully."); } catch (Exception ex) { - Logger.LogErrorMessage("Command was not successfully executed. See the error message in console for further details"); - ConsoleSpec.WriteErrorMessage(ex.Message); + _logger.LogErrorMessage("Command was not successfully executed. See the error message in console for further details"); + _consoleSpec.WriteErrorMessage(ex.Message); } - Logger.LogInfoMessage("Resetting the console's formatting.."); - Logger.LogNoteMessage("This is to make sure no error messages or one-off formating change corrupts the console environment."); - ConsoleSpec.ResetConsoleColour(); - Logger.LogSuccessMessage("Console's formating has been reset"); + _logger.LogInfoMessage("Resetting the console's formatting.."); + _logger.LogNoteMessage("This is to make sure no error messages or one-off formating change corrupts the console environment."); + _consoleSpec.ResetConsoleColour(); + _logger.LogSuccessMessage("Console's formating has been reset"); } } internal string DisplayHelpSection(string commandsNamespace) { - Logger.LogInfoMessage("Attempting to display help section.."); - var commandClasses = CommSpec.GetCommandClasses(commandsNamespace); + _logger.LogInfoMessage("Attempting to display help section.."); + var commandClasses = _commSpec.GetCommandClasses(commandsNamespace); if (commandClasses.Count == 0) { - Logger.LogErrorMessage("Unable to find any help information. Make sure the commands hace the correct atrributes applied"); - ConsoleSpec.WriteErrorSuffix(); + _logger.LogErrorMessage("Unable to find any help information. Make sure the commands hace the correct atrributes applied"); + _consoleSpec.WriteErrorSuffix(); return "Unable to find help information"; } - Logger.LogSuccessMessage("Found help information"); - Logger.LogInfoMessage("Attempting to display the help information.."); - ConsoleSpec.WriteOutputToConsole("Displaying Help section."); - ConsoleSpec.LineBreak(); - var commandMembers = HelpSpec.GetCommandMembers(commandClasses); + _logger.LogSuccessMessage("Found help information"); + _logger.LogInfoMessage("Attempting to display the help information.."); + _consoleSpec.WriteOutputToConsole("Displaying Help section."); + _consoleSpec.LineBreak(); + var commandMembers = _helpSpec.GetCommandMembers(commandClasses); foreach (var command in commandMembers) { - if (HelpSpec.ListCommand(command) == true) + if (_helpSpec.ListCommand(command) == true) { - ConsoleSpec.WriteOutputToConsole($"Command Name: {command.Name}"); - ConsoleSpec.WriteOutputToConsole($"Parameters: {HelpSpec.GetParametres(command)}"); - ConsoleSpec.WriteOutputToConsole($"Description: {HelpSpec.GetDescription(command)}"); - ConsoleSpec.WriteOutputToConsole($"Example: {HelpSpec.GetUsageExamples(command)}"); - ConsoleSpec.LineBreak(); + _consoleSpec.WriteOutputToConsole($"Command Name: {command.Name}"); + _consoleSpec.WriteOutputToConsole($"Parameters: {_helpSpec.GetParametres(command)}"); + _consoleSpec.WriteOutputToConsole($"Description: {_helpSpec.GetDescription(command)}"); + _consoleSpec.WriteOutputToConsole($"Example: {_helpSpec.GetUsageExamples(command)}"); + _consoleSpec.LineBreak(); } } - Logger.LogSuccessMessage("Help section displayed in the console"); + _logger.LogSuccessMessage("Help section displayed in the console"); return "End of Help section."; } } diff --git a/Console.Waterworks/Console.Waterworks/Constants/CW_Constants.cs b/Console.Waterworks/Console.Waterworks/Constants/CW_Constants.cs index e4c8335..52e3b4f 100644 --- a/Console.Waterworks/Console.Waterworks/Constants/CW_Constants.cs +++ b/Console.Waterworks/Console.Waterworks/Constants/CW_Constants.cs @@ -3,12 +3,15 @@ class CW_Constants { /// - /// This represents the maximum number of properties the console can display when the client "DisplayProgramInfo" to true. This is used mostly for logging purposes. + /// This represents the maximum number of properties the console can display when the client "DisplayProgramInfo" to true. + /// This is used mostly for logging purposes. /// public const int PROGRAM_INFO_PROPERTIES_COUNT = 4; /// - /// This specifies the name of the class WaterWorks looks for when it tries to build its command library. This class should not be in WaterWorks. It should be in the clients console program. + /// This specifies the name of the class Console.WaterWorks looks for when it tries to build its command library. + /// This class should not be in Console.WaterWorks. + /// It should be in the clients console program. /// public const string COMMAND_CLASS_NAME = "ConsoleCommands"; } diff --git a/Console.Waterworks/Console.Waterworks/Properties/AssemblyInfo.cs b/Console.Waterworks/Console.Waterworks/Properties/AssemblyInfo.cs index 7be9596..c03525b 100644 --- a/Console.Waterworks/Console.Waterworks/Properties/AssemblyInfo.cs +++ b/Console.Waterworks/Console.Waterworks/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ -using System.Resources; -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Reflection; +using System.Resources; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Console.Waterworks/Console.Waterworks/Specialists/CommandsSpecialist.cs b/Console.Waterworks/Console.Waterworks/Specialists/CommandsSpecialist.cs index c0784be..534f8cc 100644 --- a/Console.Waterworks/Console.Waterworks/Specialists/CommandsSpecialist.cs +++ b/Console.Waterworks/Console.Waterworks/Specialists/CommandsSpecialist.cs @@ -1,15 +1,15 @@ -using System; +using Console.Waterworks.Assistants; +using Console.Waterworks.Models; +using System; using System.Collections.Generic; using System.Linq; -using Console.Waterworks.Models; using System.Reflection; -using Console.Waterworks.Assistants; namespace Console.Waterworks.Specialists { class CommandsSpecialist { - CommandsAssistant Assistant = new CommandsAssistant(); + CommandsAssistant _assistant = new CommandsAssistant(); internal List GetCommandClasses(string commandsNameSpace) { @@ -39,21 +39,21 @@ namespace Console.Waterworks.Specialists internal string ExecuteCommand(string commandsNamespace, Command command, List commandClasses, Dictionary>> commandLibraries, ConsoleIOSpecialist consoleSpec) { - var classValidated = Assistant.ValidateClass(command, commandLibraries); - var commandNameValidated = Assistant.ValidateCommand(command, commandLibraries); + var classValidated = _assistant.ValidateClass(command, commandLibraries); + var commandNameValidated = _assistant.ValidateCommand(command, commandLibraries); Dictionary> methodDictionary; if (classValidated != true || commandNameValidated != true) - return Assistant.ExecuteBadCommandProcedure(command, consoleSpec); + return _assistant.ExecuteBadCommandProcedure(command, consoleSpec); else methodDictionary = commandLibraries[command.ClassName]; var paramInfoList = methodDictionary[command.Name].ToList(); - var paramsValidated = Assistant.ValidateParamArguments(command, paramInfoList); + var paramsValidated = _assistant.ValidateParamArguments(command, paramInfoList); if (paramsValidated == false) - return Assistant.ExecuteMissingArgumentProcedure(command, paramInfoList, consoleSpec); - var methodParametreValueList = Assistant.GetParametreValueList(command, paramInfoList); - var typeInfo = Assistant.BuildCommandLibraryClass(command, commandsNamespace); - var inputArguments = Assistant.GetInputArguments(methodParametreValueList); - var result = Assistant.InvokeCommand(command, typeInfo, inputArguments); + return _assistant.ExecuteMissingArgumentProcedure(command, paramInfoList, consoleSpec); + var methodParametreValueList = _assistant.GetParametreValueList(command, paramInfoList); + var typeInfo = _assistant.BuildCommandLibraryClass(command, commandsNamespace); + var inputArguments = _assistant.GetInputArguments(methodParametreValueList); + var result = _assistant.InvokeCommand(command, typeInfo, inputArguments); return result; } }