-
Notifications
You must be signed in to change notification settings - Fork 483
Open
Labels
Milestone
Description
public class MyOption
{
[Option('t', "type", Required = true, HelpText = "My entity")]
public EntityType MyEntityType { get; set; }
public enum MyEntityType
{
X0, // Example for X0 is empty. If change this line to X0 =1, everything is ok
X1,
X2
}
[Usage(ApplicationAlias = "...")]
public static IEnumerable<Example> Examples
{
get
{
foreach (EntityType entityType in Enum.GetValues(typeof(EntityType)))
{
yield return new Example(entityType.ToString(), new MyOption { MyEntityType = entityType});
}
}
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
nemec commentedon Dec 8, 2018
This looks like a bug around examples with
Required
set to true. The example is empty becauseX0
is the default value for this enum - if you removeRequired
you'll find thatmyapp.exe
with no arguments setsMyEntityType
toX0
automatically.myapp.exe
andmyapp.exe -t X0
produce the exact same result.But the example generator should look at whether the option is required and include it whether or not it's the default value.
njqdev commentedon Jun 2, 2019
I took a look at this again and noticed that other value types have the same issue.
Returns
and the same example with non-default values returns
The enum is included in both examples too, because of the change I made in #452.
shubhiroy commentedon Aug 6, 2023
If you are looking for help on this.. I would be glad to take it up @nemec @ericnewton76 @moh-hassan
It would be my first open-source contribution
Thanks In Advance :)