forked from commandlineparser/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseAttribute.cs
More file actions
121 lines (109 loc) · 3.37 KB
/
Copy pathBaseAttribute.cs
File metadata and controls
121 lines (109 loc) · 3.37 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
using System;
namespace CommandLine
{
/// <summary>
/// Models a base attribute to define command line syntax.
/// </summary>
public abstract class BaseAttribute : Attribute
{
private int min;
private int max;
private object @default;
private string helpText;
private string metaValue;
/// <summary>
/// Initializes a new instance of the <see cref="CommandLine.BaseAttribute"/> class.
/// </summary>
protected internal BaseAttribute()
{
min = -1;
max = -1;
helpText = string.Empty;
metaValue = string.Empty;
}
/// <summary>
/// Gets or sets a value indicating whether a command line option is required.
/// </summary>
public bool Required
{
get;
set;
}
/// <summary>
/// When applied to <see cref="System.Collections.Generic.IEnumerable{T}"/> properties defines
/// the lower range of items.
/// </summary>
/// <remarks>If not set, no lower range is enforced.</remarks>
public int Min
{
get { return min; }
set
{
if (value < 0)
{
throw new ArgumentNullException("value");
}
min = value;
}
}
/// <summary>
/// When applied to <see cref="System.Collections.Generic.IEnumerable{T}"/> properties defines
/// the upper range of items.
/// </summary>
/// <remarks>If not set, no upper range is enforced.</remarks>
public int Max
{
get { return max; }
set
{
if (value < 0)
{
throw new ArgumentNullException("value");
}
max = value;
}
}
/// <summary>
/// Gets or sets mapped property default value.
/// </summary>
public object Default
{
get { return @default; }
set
{
@default = value;
}
}
/// <summary>
/// Gets or sets a short description of this command line option. Usually a sentence summary.
/// </summary>
public string HelpText
{
get { return helpText; }
set
{
helpText = value ?? throw new ArgumentNullException("value");
}
}
/// <summary>
/// Gets or sets mapped property meta value. Usually an uppercase hint of required value type.
/// </summary>
public string MetaValue
{
get { return metaValue; }
set
{
metaValue = value ?? throw new ArgumentNullException("value");
}
}
/// <summary>
/// Gets or sets a value indicating whether a command line option is visible in the help text.
/// </summary>
public bool Hidden
{
get;
set;
}
}
}