From 284021c523c7b89bb9c5ce1890cc91c3cdd9e903 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Apr 2017 08:34:02 -0400 Subject: [PATCH] Document terminal command system --- ShiftOS_TheReturn/Command.cs | 100 +++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/ShiftOS_TheReturn/Command.cs b/ShiftOS_TheReturn/Command.cs index a5924ed..c6d58e1 100644 --- a/ShiftOS_TheReturn/Command.cs +++ b/ShiftOS_TheReturn/Command.cs @@ -30,23 +30,53 @@ using System.Threading.Tasks; namespace ShiftOS.Engine { + /// + /// Denotes that the following terminal command or namespace must only be used in an elevated environment. + /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] public class KernelModeAttribute : Attribute { } + /// + /// Denotes that the following public static method is a ShiftOS Terminal command. + /// + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class Command : Attribute { + /// + /// The command name. + /// public string name; + /// + /// The description of the command. + /// public string description = ""; + /// + /// The usage flags for the command. + /// public string usage = ""; + /// + /// Should the command be hidden from the help system? + /// public bool hide = false; + /// + /// Creates a new instance of the . + /// + /// The name of the command. public Command(string name) { this.name = name; } + + + /// + /// Creates a new instance of the . + /// + /// The name of the command. + /// Whether the command should be hidden from the help system. public Command(string name, bool hide) { this.name = name; @@ -60,9 +90,20 @@ namespace ShiftOS.Engine } } + /// + /// Denotes that this function or property is dependent on a Shiftorium upgrade. + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public class RequiresUpgradeAttribute : Attribute { + /// + /// Gets or sets the upgrade(s) this attribute requires. + /// public string Upgrade { get; set; } + + /// + /// Gets whether the dependent upgrade(s) are installed. + /// public bool Installed { get @@ -94,14 +135,35 @@ namespace ShiftOS.Engine } } + /// + /// Denotes a Terminal command namespace. + /// public class Namespace : Attribute { + /// + /// The namespace's name. + /// public string name; + /// + /// Whether the namespace should be hidden from the help system. Overrides all child s' hide values. + /// public bool hide; + + /// + /// Creates a new instance of the . + /// + /// The name of the namespace. public Namespace(string n) { name = n; } + + + /// + /// Creates a new instance of the . + /// + /// The name of the namespace. + /// Whether this namespace should be hidden from the user. public Namespace(string n, bool hide) { name = n; @@ -109,13 +171,34 @@ namespace ShiftOS.Engine } } + /// + /// Marks a Terminal command as obsolete. + /// [AttributeUsage(AttributeTargets.Method)] public class CommandObsolete : Attribute { + /// + /// The reason of obsolescence. + /// public string reason; + + /// + /// If a new command has the same functionality, this is it. + /// public string newcommand; + + /// + /// Should we warn the user when they run this command? + /// public bool warn; + + /// + /// Creates a new instance of the class. + /// + /// The reason for this command's obsolescence. You can use "%n" in place of the new command name. + /// If a new command is set to take over, specify it here. + /// Whether or not we should warn the user when they run the command. public CommandObsolete(string reason, string newcommand, bool warn) { this.reason = reason; // %n for newcommand @@ -124,11 +207,21 @@ namespace ShiftOS.Engine } } + /// + /// Denotes that this command requires a specified argument to be in its argument dictionary. + /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class RequiresArgument : Attribute { + /// + /// The argument name + /// public string argument; + /// + /// Creates a new instance of the attribute + /// + /// The argument name associated with this attribute public RequiresArgument(string argument) { this.argument = argument; @@ -143,12 +236,11 @@ namespace ShiftOS.Engine } } + /// + /// Prevents a command from being run in a remote session. + /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class RemoteLockAttribute : Attribute { - /// - /// When used on a terminal command, it will prevent that command from being invoked by a remote user (over MUD terminal forwarding). - /// - public RemoteLockAttribute() { } } }