Skip to content

Commit a62adb4

Browse files
committed
Added new attributes
1 parent 1aa137e commit a62adb4

24 files changed

+651
-0
lines changed

Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Debugging.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Attributes.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
3+
namespace Commander
4+
{
5+
/// <summary>
6+
/// Attribute to mark a method as an executable command.
7+
/// </summary>
8+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
9+
public class CommandAttribute : Attribute
10+
{
11+
#region Properties
12+
13+
public string Name { get; }
14+
public string Descrption { get; }
15+
public CommandRole Role { get; }
16+
17+
#endregion
18+
19+
#region Constructors
20+
21+
/// <summary>
22+
/// Default constructor for Command attribute.
23+
/// </summary>
24+
public CommandAttribute()
25+
{
26+
Name = string.Empty;
27+
Descrption = string.Empty;
28+
Role = CommandRole.Any;
29+
}
30+
31+
/// <summary>
32+
/// Constructor for Command attribute with the comamnd name.
33+
/// </summary>
34+
/// <param name="name">Command name called in command-line</param>
35+
public CommandAttribute(string name)
36+
{
37+
Name = name;
38+
Descrption = string.Empty;
39+
Role = CommandRole.Any;
40+
}
41+
42+
/// <summary>
43+
/// Constructor for Command attribute with the command name and it's description.
44+
/// </summary>
45+
/// <param name="name">This command's name called in command-line</param>
46+
/// <param name="description">This command's description of what it does</param>
47+
public CommandAttribute(string name, string description)
48+
{
49+
Name = name;
50+
Descrption = description;
51+
Role = CommandRole.Any;
52+
}
53+
54+
/// <summary>
55+
/// Constructor for Command attribute with the command name, description, and role.
56+
/// </summary>
57+
/// <param name="name">This command's name called in command-line</param>
58+
/// <param name="description">This command's description of what it does</param>
59+
/// <param name="role">This command's execution permission role</param>
60+
public CommandAttribute(string name, string description, CommandRole role)
61+
{
62+
Name = name;
63+
Descrption = description;
64+
Role = role;
65+
}
66+
67+
/// <summary>
68+
/// Constructor for Command attribute with the command name and role.
69+
/// </summary>
70+
/// <param name="name">This command's name called in command-line</param>
71+
/// <param name="role">This command's execution permission role</param>
72+
public CommandAttribute(string name, CommandRole role)
73+
{
74+
Name = name;
75+
Role = CommandRole.Any;
76+
Descrption = string.Empty;
77+
}
78+
79+
#endregion
80+
}
81+
}

Runtime/Attributes/CommandAttribute.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
3+
namespace Commander
4+
{
5+
/// <summary>
6+
/// Attribute to mark a method with a specific role.
7+
/// </summary>
8+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
9+
public class CommandRoleAttribute : Attribute
10+
{
11+
public CommandRole Role { get; }
12+
13+
public CommandRoleAttribute(CommandRole role)
14+
{
15+
Role = role;
16+
}
17+
}
18+
}

Runtime/Attributes/CommandRoleAttribute.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace Commander
4+
{
5+
/// <summary>
6+
/// Attribute to hide a command from the command list.
7+
/// </summary>
8+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
9+
public class HiddenCommandAttribute : Attribute
10+
{
11+
// This attribute does not require any properties or methods.
12+
// It serves as a marker to indicate that the command should not be
13+
// displayed in the command list
14+
}
15+
}

Runtime/Attributes/HiddenCommandAttribute.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)