Skip to content

dev:Command

Väinämö Łūmikērø edited this page Feb 2, 2017 · 3 revisions

Command

F2Core.Command.Command

Provides functions to validate and parse commands. See Command Handling for further information.


Construction

Command(string name, string @namespace, string definer = "\\/")
Command(string name, F2Core.Extension.IExtension extension, string definer = "\\/")
  • string name
    The name of this command. Can only contain letters, numbers and -.
  • string @namespace
    The namespace of the extension registering this command.
  • F2Core.Extension.IExtension extension
    The extension registering this command.
  • string definer
    Optional. Change if the command should not be invoked with a leading slash /.
    Needs be to escaped for regex.

Properties

  • string Definer
    The sequence defining the invokation of this command. By default a leading slash /.
  • string Name
    The name of this command.
  • string Namespace
    The namespace of the extension registering this command.

Methods

void AddParameter<T>(string, int, F2Core.Command.ParameterType)

void AddParameter<T>(string name, int index, F2Core.Command.ParameterType parameterType) where T : IConvertible

Add a new parameter to the command.

  • T <T>
    The type the parameter requires. Can be string, bool, double or int as of now.
  • string name
    The name of this parameter. Can only contain letters, numbers and -.
  • int index
    Defines the order of this parameter. Needs to be distinct. Required parameters cannot follow optional parameters.
  • F2Core.Command.ParameterType parameterType
    Defines whether the parameter is ParameterType.Optional or ParameterType.Required.

T Parse<T>(string, string)

T Parse<T>(string content, string parameter) where T : IConvertible

Parses a command and returns the parameter value or the default value of the parameter type if the command doesn't match.

  • T <T>
    The type the parameter requires. Can be string, bool, double or int as of now.
  • string content
    The content to parse.
  • string parameter
    The parameter value to return.
  • T (return)
    Returns the parsed value or the default value of T.

bool Validate(string)

bool Validate(string content)

Validates a command.

  • string content
    The content to validate.
  • bool (return)
    Returns true if the content matches the command pattern.