Skip to content

Commit 99ae4bb

Browse files
committed
Remove IgnoreAttribute. Fields are now fundamentally only considered if they have one of [Option], [EnumOptions] or [IsPositional].
1 parent ae2040b commit 99ae4bb

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

Src/CmdLineExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ public static ConsoleColoredString FormatParameterUsage(this FieldInfo field, bo
7070

7171
public static IEnumerable<FieldInfo> GetCommandLineFields(this Type type) =>
7272
type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
73-
.Where(f => !f.IsDefined<IgnoreAttribute>())
73+
.Where(f => f.IsDefined<OptionAttribute>() || f.IsDefined<EnumOptionsAttribute>() || f.IsDefined<IsPositionalAttribute>())
7474
.OrderBy(f => f.DeclaringType.SelectChain(t => t.BaseType).Count());
7575
}

Src/CommandLineParser.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace RT.CommandLine;
2020
/// It must be a reference type (a class) and it must have a parameterless constructor.</description></item>
2121
/// <item><description>
2222
/// <para>
23-
/// Every field in the class must have one of the following custom attributes:</para>
23+
/// Field with any of the following custom attributes are processed by <see cref="CommandLineParser"/>:</para>
2424
/// <list type="bullet">
2525
/// <item><description>
2626
/// <see cref="IsPositionalAttribute"/> (allowed for all supported types except <c>bool</c>) — specifies
@@ -35,8 +35,7 @@ namespace RT.CommandLine;
3535
/// parameter that can be invoked by one of several options, which are specified on the enum values in the
3636
/// enum type.</description></item>
3737
/// <item><description>
38-
/// <see cref="IgnoreAttribute"/> — specifies that <see cref="CommandLineParser"/> shall completely ignore
39-
/// the field.</description></item></list></description></item>
38+
/// Any field that has none of those three is completely ignored.</description></item></list></description></item>
4039
/// <item><description>
4140
/// <para>
4241
/// Each field may optionally have any of the following custom attributes:</para>
@@ -113,10 +112,9 @@ namespace RT.CommandLine;
113112
/// <item><description>
114113
/// <para>
115114
/// Every field must have documentation or be explicitly marked with <see cref="UndocumentedAttribute"/>,
116-
/// except for fields that use <see cref="EnumOptionsAttribute"/> or <see cref="IgnoreAttribute"/>. For every
117-
/// field whose type is an enum type, the values in the enum type must also have documentation or <see
118-
/// cref="UndocumentedAttribute"/>, except for the enum value that corresponds to the field’s default value if
119-
/// the field is not mandatory.</para>
115+
/// except for fields that use <see cref="EnumOptionsAttribute"/>. For every field whose type is an enum type,
116+
/// the values in the enum type must also have documentation or <see cref="UndocumentedAttribute"/>, except
117+
/// for the enum value that corresponds to the field’s default value if the field is not mandatory.</para>
120118
/// <para>
121119
/// Documentation is provided in one of the following ways:</para>
122120
/// <list type="bullet">
@@ -850,8 +848,6 @@ private static void postBuildStep(IPostBuildReporter rep, Type commandLineType,
850848

851849
foreach (var enumField in field.FieldType.GetFields(BindingFlags.Static | BindingFlags.Public))
852850
{
853-
if (enumField.IsDefined<IgnoreAttribute>())
854-
continue;
855851
// If the field is not mandatory, it is allowed to have a default value
856852
if (!mandatory && enumField.GetValue(null).Equals(defaultValue))
857853
continue;

0 commit comments

Comments
 (0)