mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-01 18:38:16 +08:00
Add support for arrays in [DefaultValue] attributes (#1164)
Fixes #1163
This commit is contained in:
@ -9,4 +9,9 @@ public class LionSettings : CatSettings
|
||||
[CommandOption("-c <CHILDREN>")]
|
||||
[Description("The number of children the lion has.")]
|
||||
public int Children { get; set; }
|
||||
|
||||
[CommandOption("-d <DAY>")]
|
||||
[Description("The days the lion goes hunting.")]
|
||||
[DefaultValue(new[] { DayOfWeek.Monday, DayOfWeek.Thursday })]
|
||||
public DayOfWeek[] HuntDays { get; set; }
|
||||
}
|
||||
|
@ -33,3 +33,18 @@ public sealed class RequiredArgumentWithDefaultValueSettings : CommandSettings
|
||||
[DefaultValue("Hello World")]
|
||||
public string Greeting { get; set; }
|
||||
}
|
||||
|
||||
public sealed class OptionWithArrayOfEnumDefaultValueSettings : CommandSettings
|
||||
{
|
||||
[CommandOption("--days")]
|
||||
[DefaultValue(new[] { DayOfWeek.Sunday, DayOfWeek.Saturday })]
|
||||
public DayOfWeek[] Days { get; set; }
|
||||
}
|
||||
|
||||
public sealed class OptionWithArrayOfStringDefaultValueAndTypeConverterSettings : CommandSettings
|
||||
{
|
||||
[CommandOption("--numbers")]
|
||||
[DefaultValue(new[] { "2", "3" })]
|
||||
[TypeConverter(typeof(StringToIntegerConverter))]
|
||||
public int[] Numbers { get; set; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user