Skip to content

Consider making IValueDescriptor.GetDefaultValue() easier to use with options #1975

Open
@ghost

Description

Hey there! I'm writing some command examples for custom help output, and I had a little difficulty finding the default value for an option from the ParseResult. This is what I ended up with:

if(((IValueDescriptor)opt).HasDefaultValue)
    object? value = ((IValueDescriptor)opt).GetDefaultValue();

It would be very helpful I was not required to cast the option, and the method didn't throw an exception if there was no default. In that case, I could get the default value by writing something like:

object? value = opt.GetDefaultValue();

Arguments already make the method and field available. It would still be helpful to have this functionality for options too, even if it isn't possible to get around the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions