Skip to content

Simplify custom parsers and default value factories #2053

Closed
@adamsitnik

Description

@adamsitnik

From #2046 :

Argument<T> provides multiple ways of setting default value: as T, Func<T> and Func<ArgumentResult, T>.
What I don't like is the fact that the last ctor requires the user to define whether given Func<ArgumentResult, T> is a default value provider or a custom parser. It's confusing. We need to find a way of providing Func<ArgumentResult, T> without specifying whether it's a default value provider or just a custom parser.

It applies to both Argument<T> and Option<T>

public Argument(Func<T> defaultValueFactory)
    
public Argument(
    string name,
    T defaultValue,
    string? description = null)

public Argument(
    string? name,
    Func<ArgumentResult, T> parse,
    bool isDefault = false,
    string? description = null)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions