Browse Source

Added Help section attributes the command-methods.

Fixes some spelling mistakes and made minor changes to the assembly information.
merge-requests/1/head
Craig Oates 7 years ago
parent
commit
371285afba
  1. 84
      Console.Waterworks/CW_Console/ConsoleCommands.cs
  2. 2
      Console.Waterworks/CW_Console/Program.cs
  3. 11
      Console.Waterworks/CW_Console/Properties/AssemblyInfo.cs
  4. 8
      Console.Waterworks/Console.Waterworks/Attributes/ParametersAttribute.cs
  5. 2
      Console.Waterworks/Console.Waterworks/CoOrdinators/CoOrdinator.cs
  6. 4
      Console.Waterworks/Console.Waterworks/Specialists/HelpSpecialist.cs

84
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("<string> 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("<int> 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> int, <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("<int> int1, <double1> 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
}

2
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...
}
}
}

11
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")]

8
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;
}
}
}

2
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();

4
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<ParametresAttribute>(attributes);
return (castedAttributes != null) ? castedAttributes.Parametres : "Parametres values could not be found";
var castedAttributes = CheckForAttributesType<ParametersAttribute>(attributes);
return (castedAttributes != null) ? castedAttributes.Parameters : "Parameters values could not be found";
}
internal object GetDescription(MemberInfo command)

Loading…
Cancel
Save