Merge branch 'master' of https://gitnext.lewd.wtf/PGR/ascnet
This commit is contained in:
commit
e7b9d4ac04
|
@ -58,14 +58,19 @@ namespace AscNet.GameServer.Commands
|
||||||
public class ArgumentAttribute : Attribute
|
public class ArgumentAttribute : Attribute
|
||||||
{
|
{
|
||||||
public int Position { get; }
|
public int Position { get; }
|
||||||
public Regex Pattern { get; }
|
public Regex Pattern { get; set; }
|
||||||
public string? Description { get; }
|
public string? Description { get; }
|
||||||
public ArgumentFlags Flags { get; }
|
public ArgumentFlags Flags { get; }
|
||||||
|
|
||||||
public ArgumentAttribute(int position, string pattern, string? description = null, ArgumentFlags flags = ArgumentFlags.None)
|
public ArgumentAttribute(int position, string pattern, string? description = null, ArgumentFlags flags = ArgumentFlags.None)
|
||||||
{
|
{
|
||||||
Position = position;
|
Position = position;
|
||||||
Pattern = new(pattern);
|
|
||||||
|
if ((flags & ArgumentFlags.IgnoreCase) != ArgumentFlags.IgnoreCase)
|
||||||
|
Pattern = new(pattern);
|
||||||
|
else
|
||||||
|
Pattern = new(pattern, RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
Description = description;
|
Description = description;
|
||||||
Flags = flags;
|
Flags = flags;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +79,8 @@ namespace AscNet.GameServer.Commands
|
||||||
public enum ArgumentFlags
|
public enum ArgumentFlags
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Optional = 1
|
Optional = 1,
|
||||||
|
IgnoreCase = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace AscNet.GameServer.Commands
|
||||||
|
|
||||||
public override string Help => "Command to interact with user's items";
|
public override string Help => "Command to interact with user's items";
|
||||||
|
|
||||||
[Argument(0, @"^add$|^clear$|^reset$", "The operation selected (add, clear, reset)")]
|
[Argument(0, @"^add$|^clear$|^reset$", "The operation selected (add, clear, reset)", ArgumentFlags.IgnoreCase)]
|
||||||
string Op { get; set; } = string.Empty;
|
string Op { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Argument(1, @"^[0-9]+$|^all$", "The target item, value is item id or 'all'", ArgumentFlags.Optional)]
|
[Argument(1, @"^[0-9]+$|^all$", "The target item, value is item id or 'all'", ArgumentFlags.Optional)]
|
||||||
|
@ -22,7 +22,7 @@ namespace AscNet.GameServer.Commands
|
||||||
|
|
||||||
public override void Execute()
|
public override void Execute()
|
||||||
{
|
{
|
||||||
switch (Op)
|
switch (Op.ToLower())
|
||||||
{
|
{
|
||||||
case "add":
|
case "add":
|
||||||
if (Target == "all")
|
if (Target == "all")
|
||||||
|
|
Loading…
Reference in New Issue