Console.Waterworks.Core is the .Net Core version of Console.Waterworks. https://www.craigoates.net/Software/project/8
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.9 KiB

using System;
using Console.Waterworks.Core.Attributes;
using Console.Waterworks.Core;
namespace CW_Core_Console
{
public class ConsoleCommands
{
#region Demo-Methods
// These command-methods are to show how a Console.Waterworks program typically looks.
[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_Core_Console");
}
[ListCommand()]
[Description("Outputs a message indicating this program is running okay.")]
[Parameters("None")]
[Usage("CW_Console> Test")]
public static string Test() => "Test complete.";
[ListCommand()]
[Description("Repeats back to the user the string they entered.")]
[Parameters("<string> input")]
[Usage("CW_Console> Say \"Hello, World.\"")]
public static string Say(string input) => $"{input}";
[ListCommand()]
[Description("Displays the date and time at the moment the command is entered")]
[Parameters("None")]
[Usage("CW_Console> GetDate")]
public static string GetDate() => $"{DateTime.Now}";
[ListCommand()]
[Description("Takes the two ints and adds them together.")]
[Parameters("<int> int, <int> int2")]
[Usage("CW_Console> Add 31 10")]
public static string Add(int int1, int int2) => $"{int1} + {int2} = {int1 + int2}";
[ListCommand()]
[Description("Terminates the program.")]
[Parameters("None")]
[Usage("CW_Console> Quit")]
public static void Quit() => Environment.Exit(-1);
#endregion
#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 \"Test\". See \"Test\" for details.")]
[Parameters("None")]
[Usage("CW_Console> test")]
public static string test() => Test();
[ListCommand(false)]
[Description("Alias for \"Say\". See \"Say\" for details.")]
[Parameters("None")]
[Usage("CW_Console> say \"Hello, World.\"")]
public static string say(string input) => Say(input);
[ListCommand(false)]
[Description("Alias for \"GetDate\". See \"GetDate\" for details.")]
[Parameters("None")]
[Usage("CW_Console> date")]
public static string date() => GetDate();
[ListCommand(false)]
[Description("Alias for \"Add\". See \"Add\" for details.")]
[Parameters("None")]
[Usage("CW_Console> add 24 67")]
public static string add(int int1, int int2) => Add(int1, int2);
[ListCommand(false)]
[Description("Alias for Quit. See Quit for details.")]
[Parameters("None")]
[Usage("CW_Console> quit")]
public static void quit() => Quit();
#endregion
#region Test-Methods
// The command-methods are for testing purposes only.
// You can use them at run-time but they will not appear in the help section.
// The template
// public static string paramTest(int param1) => $"Param: {param1}";
public static string StringTest(String param1) => $"{param1}";
public static string Int16Test(Int16 param1) => $"{param1}";
public static string Int32Test(Int32 param1) => $"{param1}";
public static string Int64Test(Int64 param1) => $"{param1}";
public static string BooleanTest(Boolean param1) => $"{param1}";
public static string ByteTest(Byte param1) => $"{param1}";
public static string CharTest(Char param1) => $"{param1}";
public static string DateTimeTest(DateTime param1) => $"{param1}";
public static string DecimalTest(Decimal param1) => $"{param1}";
public static string SingleTest(Single param1) => $"{param1}";
public static string UInt16Test(UInt16 param1) => $"{param1}";
public static string UInt32Test(UInt32 param1) => $"{param1}";
public static string UInt64Test(UInt64 param1) => $"{param1}";
#endregion
}
}