-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathParsedOption.cs
More file actions
36 lines (32 loc) · 1.37 KB
/
ParsedOption.cs
File metadata and controls
36 lines (32 loc) · 1.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
using BytecodeApi.Extensions;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace BytecodeApi.CommandLineParser;
/// <summary>
/// Represents a commandline option, parsed from a given commandline. An <see cref="CommandLineParser.Option" /> reference identifies the option.
/// </summary>
[DebuggerDisplay($"{nameof(ParsedOption)}: Option: {{DebuggerDisplayOption}}, Values: {{DebuggerDisplayValues}}")]
public sealed class ParsedOption
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplayOption => Option.Arguments.First();
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string DebuggerDisplayValues => Values.Count == 1 ? Values.First() : Values.AsString(", ");
/// <summary>
/// Gets a reference to the associated <see cref="CommandLineParser.Option" /> this <see cref="ParsedOption" /> is associated with.
/// </summary>
public Option Option { get; }
/// <summary>
/// Gets a <see cref="string" /> collection with the parsed values.
/// </summary>
public ReadOnlyCollection<string> Values { get; }
internal ParsedOption(Option option, string[] values)
{
Check.ArgumentNull(option);
Check.ArgumentNull(values);
Check.ArgumentEx.ArrayValuesNotNull(values);
Check.ArgumentEx.ArrayValuesNotStringEmpty(values);
Option = option;
Values = values.ToReadOnlyCollection();
}
}