From d1e874ed4733e557f9502d514a24b54188f31095 Mon Sep 17 00:00:00 2001 From: That_One_Nerd Date: Thu, 16 Mar 2023 12:00:59 -0400 Subject: [PATCH] added page --- Commands.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Commands.md diff --git a/Commands.md b/Commands.md new file mode 100644 index 0000000..03ffb63 --- /dev/null +++ b/Commands.md @@ -0,0 +1,53 @@ +# Overview +Commands are methods inside a [module](Modules) that the shell will execute when a command that fits its module ID (if applicable) and name ID is run. A command can have as many parameters as required and the types for those parameters vary. + +## How to Use +Commands must be in a [module](Modules) to be recognized. Any commands not inside their respective modules will be ignored. Commands are declared by applying the `CommandAttribute` attribute in the namespace `SrcMod.Shell.Modules.ObjectModels` to a method. The method can be static. The return type must be `void` and all parameters must have the following types: + +| Type | +|-| +| `sbyte` (`System.SByte`) | +| `byte` (`System.Byte`) | +| `short` (`System.Int16`) | +| `ushort` (`System.UInt16`) | +| `int` (`System.Int32`) | +| `uint` (`System.UInt32` | +| `long` (`System.Int64`) | +| `ulong` (`System.UInt64`) | +| `System.Int128` | +| `System.UInt128` | +| `nint` (`System.IntPtr`) | +| `nuint` (`System.UIntPtr`) | +| `System.Half` | +| `float` (`System.Single`) | +| `double` (`System.Double`) | +| `decimal` (`System.Decimal`) | +| `char` (`System.Char`) | +| `System.DateOnly` | +| `System.DateTime` | +| `System.DateTimeOffset` | +| `System.Guid` | +| `System.TimeOnly` | +| `System.TimeSpan` | + +Here is an example: +```csharp +// Used for the `CommandAttribute` and `ModuleAttribute`. +using SrcMod.Shell.Modules.ObjectModels; + +[Module("example")] +public static class ExampleModule +{ + [Command("command")] + public static void ExampleCommand() + { + // Invoked by executing "example command" + } +} +``` + +As said earlier, commands can have parameters as long as they fit the earlier given types or can be implicitly or explicitly casted from them. During the parsing process, parameters are split by spaces (except if in quotations). + +--- + +**Note: When using the `srcmod.dll` to add additional custom modules, the new modules will not be recognized due to a reflection bug. This will be fixed in the near future (see issue #2).**