From 371285afbac9e65846233ee1c0d31773ed946d61 Mon Sep 17 00:00:00 2001 From: Craig_Oates Date: Fri, 22 Sep 2017 23:17:03 +0100 Subject: [PATCH] Added Help section attributes the command-methods. Fixes some spelling mistakes and made minor changes to the assembly information. --- .../CW_Console/ConsoleCommands.cs | 84 +++++++++++++++++-- Console.Waterworks/CW_Console/Program.cs | 2 + .../CW_Console/Properties/AssemblyInfo.cs | 11 ++- .../Attributes/ParametersAttribute.cs | 8 +- .../CoOrdinators/CoOrdinator.cs | 2 +- .../Specialists/HelpSpecialist.cs | 4 +- 6 files changed, 93 insertions(+), 18 deletions(-) diff --git a/Console.Waterworks/CW_Console/ConsoleCommands.cs b/Console.Waterworks/CW_Console/ConsoleCommands.cs index 240b1b2..77b6171 100644 --- a/Console.Waterworks/CW_Console/ConsoleCommands.cs +++ b/Console.Waterworks/CW_Console/ConsoleCommands.cs @@ -1,35 +1,105 @@ using Console.Waterworks; +using Console.Waterworks.Attributes; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace CW_Console { public static class ConsoleCommands { + [ListCommand()] + [Description("Displays the Help section at run-time")] + [Parameters("None")] + [Usage("CW_Console> Help")] public static string Help() { CW_Liaison liaison = new CW_Liaison(); return liaison.RequestHelpDocumentation("CW_Console"); } + [ListCommand()] + [Description("Outputs to the console the command has been completed.")] + [Parameters("None")] + [Usage("CW_Console> Command1")] public static string Command1() => "Command1 has completed"; + + [ListCommand()] + [Description("Repeats back to the user the string they entered.")] + [Parameters(" input")] + [Usage("CW_Console> Command2 \"Hello, World.\"")] public static string Command2(string input) => $"Command2 has completed... {input} was entered"; + + [ListCommand()] + [Description("Repeats back to the user what int they entered.")] + [Parameters(" int1")] + [Usage("CW_Console> Command3 31")] public static string Command3(int input) => $"Command3 has completed... The number {input} was entered"; + + [ListCommand()] + [Description("Takes the two ints and adds them together.")] + [Parameters(" int, int2")] + [Usage("CW_Console> Command4 31 10")] public static string Command4(int int1, int int2) => $"Command4 has completed... {int1} and {int2} was entered and make {int1 + int2} when added together"; + + [ListCommand()] + [Description("Take the int and double and adds them together.")] + [Parameters(" int1, double1")] + [Usage("CW_Console> 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()] + [Description("Terminates the program.")] + [Parameters("None")] + [Usage("CW_Console> Quit")] public static void Quit() => Environment.Exit(-1); - #region Alias Methods - // These methods are shorthand versions of the ones above. - // These are useful for experienced users of your console program. + #region Alias-Methods + + /* + * A NOTE ABOUT ALIAS-METHODS - DELETE AFTER READING + * ========================================================= + * These methods are shorthand versions of the ones above. + * For the most part, this is a hack. + * But, it is a useful one. + * When new users start using your console program, they need help getting started. + * This is why I recommend using descriptive names for your command-methods. + * But, when your users become more familiar with the program, they will want terser commands. + * They will no longer need their hand holding. This is where these alias-commands come in. + */ + + [ListCommand(false)] // change to true or delete "false" for it to show at run-time. + [Description("Alias for Command1. See Command1 for details.")] + [Parameters("None")] + [Usage("CW_Console> c1")] public static string c1() => Command1(); + + [ListCommand(false)] + [Description("Alias for Command2. See Command2 for details.")] + [Parameters("None")] + [Usage("CW_Console> c2 \"Hello, World.\"")] public static string c2(string input) => Command2(input); + + [ListCommand(false)] + [Description("Alias for Command3. See Command3 for details.")] + [Parameters("None")] + [Usage("CW_Console> c3 78")] public static string c3(int input) => Command3(input); + + [ListCommand(false)] + [Description("Alias for Command4. See Command4 for details.")] + [Parameters("None")] + [Usage("CW_Console> c4 24 67")] public static string c4(int int1, int int2) => Command4(int1, int2); + + [ListCommand(false)] + [Description("Alias for Command5. See Command5 for details.")] + [Parameters("None")] + [Usage("CW_Console> c5 12 46.3")] public static string c5(int int1, double double1) => Command5(int1, double1); + + [ListCommand(false)] + [Description("Alias for Quit. See Quit for details.")] + [Parameters("None")] + [Usage("CW_Console> quit")] public static void quit() => Quit(); #endregion } diff --git a/Console.Waterworks/CW_Console/Program.cs b/Console.Waterworks/CW_Console/Program.cs index 9548340..803a7a1 100644 --- a/Console.Waterworks/CW_Console/Program.cs +++ b/Console.Waterworks/CW_Console/Program.cs @@ -13,6 +13,8 @@ namespace CW_Console { CW_Liaison bob = new CW_Liaison(); bob.Run("CW_Console", true); + // That is it. You are done here. + // Head over to ConsoleCommands.cs to begin adding features... } } } diff --git a/Console.Waterworks/CW_Console/Properties/AssemblyInfo.cs b/Console.Waterworks/CW_Console/Properties/AssemblyInfo.cs index f6acb40..a104d39 100644 --- a/Console.Waterworks/CW_Console/Properties/AssemblyInfo.cs +++ b/Console.Waterworks/CW_Console/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System.Resources; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -6,11 +7,11 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("CW_Console")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("This is the console program for testing the Console.Waterworks Nuget package.")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("Craig Oates")] [assembly: AssemblyProduct("CW_Console")] -[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyCopyright("Copyright © 2017 Craig Oates")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -34,3 +35,5 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguage("en-GB")] + diff --git a/Console.Waterworks/Console.Waterworks/Attributes/ParametersAttribute.cs b/Console.Waterworks/Console.Waterworks/Attributes/ParametersAttribute.cs index 994cea6..d412fc7 100644 --- a/Console.Waterworks/Console.Waterworks/Attributes/ParametersAttribute.cs +++ b/Console.Waterworks/Console.Waterworks/Attributes/ParametersAttribute.cs @@ -3,12 +3,12 @@ namespace Console.Waterworks.Attributes { [AttributeUsage(AttributeTargets.All)] - public class ParametresAttribute : Attribute + public class ParametersAttribute : Attribute { - public readonly string Parametres; - public ParametresAttribute(string arguments) + public readonly string Parameters; + public ParametersAttribute(string arguments) { - Parametres = arguments; + Parameters = arguments; } } } diff --git a/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs b/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs index b96efe8..78f0ef4 100644 --- a/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs +++ b/Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs @@ -83,7 +83,7 @@ namespace Console.Waterworks.CoOrdinators if (HelpSpec.ListCommand(command) == true) { ConsoleSpec.WriteOutputToConsole($"Command Name: {command.Name}"); - ConsoleSpec.WriteOutputToConsole($"Parametres: {HelpSpec.GetParametres(command)}"); + ConsoleSpec.WriteOutputToConsole($"Parameters: {HelpSpec.GetParametres(command)}"); ConsoleSpec.WriteOutputToConsole($"Description: {HelpSpec.GetDescription(command)}"); ConsoleSpec.WriteOutputToConsole($"Example: {HelpSpec.GetUsageExamples(command)}"); ConsoleSpec.LineBreak(); diff --git a/Console.Waterworks/Console.Waterworks/Specialists/HelpSpecialist.cs b/Console.Waterworks/Console.Waterworks/Specialists/HelpSpecialist.cs index 42d3de2..b7df353 100644 --- a/Console.Waterworks/Console.Waterworks/Specialists/HelpSpecialist.cs +++ b/Console.Waterworks/Console.Waterworks/Specialists/HelpSpecialist.cs @@ -42,8 +42,8 @@ namespace Console.Waterworks.Specialists internal object GetParametres(MemberInfo command) { var attributes = GetCustomAttributes(command); - var castedAttributes = CheckForAttributesType(attributes); - return (castedAttributes != null) ? castedAttributes.Parametres : "Parametres values could not be found"; + var castedAttributes = CheckForAttributesType(attributes); + return (castedAttributes != null) ? castedAttributes.Parameters : "Parameters values could not be found"; } internal object GetDescription(MemberInfo command)