forked from serdedotnet/serde.cmdline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttributes.cs
More file actions
55 lines (44 loc) · 1.51 KB
/
Attributes.cs
File metadata and controls
55 lines (44 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
namespace Serde.CmdLine;
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
AllowMultiple = false,
Inherited = false)]
public sealed class CommandOptionAttribute(string flagNames) : Attribute
{
public string FlagNames { get; } = flagNames;
public string? Description { get; init; } = null;
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
AllowMultiple = false,
Inherited = false)]
public sealed class CommandParameterAttribute(int ordinal, string name) : Attribute
{
public int Ordinal { get; } = ordinal;
public string Name { get; } = name;
public string? Description { get; init; } = null;
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Class,
AllowMultiple = false,
Inherited = false)]
public sealed class CommandAttribute(string name) : Attribute
{
public string Name { get; } = name;
/// <summary>
/// Short summary of the command.
/// </summary>
public string? Summary { get; init; } = null;
/// <summary>
/// Detailed description of the command.
/// </summary>
public string? Description { get; init; } = null;
}
/// <summary>
/// Represents one of a group of commands, also known as a discriminated union.
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
AllowMultiple = false,
Inherited = false)]
public sealed class CommandGroupAttribute(string name) : Attribute
{
public string Name { get; } = name;
}