mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-06 04:28:15 +08:00
Move Spectre.Console.Cli to it's own package
This commit is contained in:

committed by
Patrik Svensson

parent
b600832e00
commit
36ca22ffac
30
src/Spectre.Console.Cli/Internal/Modelling/CommandOption.cs
Normal file
30
src/Spectre.Console.Cli/Internal/Modelling/CommandOption.cs
Normal file
@ -0,0 +1,30 @@
|
||||
namespace Spectre.Console.Cli;
|
||||
|
||||
internal sealed class CommandOption : CommandParameter
|
||||
{
|
||||
public IReadOnlyList<string> LongNames { get; }
|
||||
public IReadOnlyList<string> ShortNames { get; }
|
||||
public string? ValueName { get; }
|
||||
public bool ValueIsOptional { get; }
|
||||
public bool IsShadowed { get; set; }
|
||||
|
||||
public CommandOption(
|
||||
Type parameterType, ParameterKind parameterKind, PropertyInfo property, string? description,
|
||||
TypeConverterAttribute? converter, PairDeconstructorAttribute? deconstructor,
|
||||
CommandOptionAttribute optionAttribute, ParameterValueProviderAttribute? valueProvider,
|
||||
IEnumerable<ParameterValidationAttribute> validators,
|
||||
DefaultValueAttribute? defaultValue, bool valueIsOptional)
|
||||
: base(parameterType, parameterKind, property, description, converter,
|
||||
defaultValue, deconstructor, valueProvider, validators, false, optionAttribute.IsHidden)
|
||||
{
|
||||
LongNames = optionAttribute.LongNames;
|
||||
ShortNames = optionAttribute.ShortNames;
|
||||
ValueName = optionAttribute.ValueName;
|
||||
ValueIsOptional = valueIsOptional;
|
||||
}
|
||||
|
||||
public string GetOptionName()
|
||||
{
|
||||
return LongNames.Count > 0 ? LongNames[0] : ShortNames[0];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user