Clone
6
Modules
That_One_Nerd edited this page 2023-04-18 09:56:41 -04:00

Overview

Modules in SrcMod are how commands are grouped. A module can have an id which must be prefixed before the command name and parameters when parsed.

How to Use

Modules are declared by applying the ModuleAttribute attribute in the namespace SrcMod.Shell.Modules.ObjectModels to a class. The classes can be static.

Here is an example:

// Used for the `ModuleAttribute`.
using SrcMod.Shell.Modules.ObjectModels;

[Module("example1")]
public static class ExampleModule1
{
    // Invoked by executing "example1 <command> <arguments>"
}

The ModuleAttribute attribute requires you to supply a nameId. This will be what prefixes the command name ID in a command string. Optionally, there is also a boolean nameIsPrefix, which by default is set to true. If the parameter is false, commands in that module will not require the module name ID to be prefixed.

// Used for the `ModuleAttribute`.
using SrcMod.Shell.Modules.ObjectModels;

[Module("example2", false)]
public static class ExampleModule2
{
    // The module ID is not a prefix.
    // Invoked by executing "<command> <arguments>"
}

Inside the class will be the commands in that module.


Default Modules

These are the name, prefix, and brief descriptions of each module implemented by default in SrcMod.

Class Name Prefix Description
BaseModule base (not prefixed) A module with most system commands. Does not contain any modding functionality.
ClipboardModule clipboard A module that handles commands related to the system clipboard.
CompressionModule compress A module that handles compression to certain formats.
ConfigModule config A module that handles configuration of the shell.
ExtractionModule extract A module that handles extraction from certain compression formats.