dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.34k stars 375 forks source link

Expand annotation accessor pattern #2417

Open KathleenDollard opened 2 months ago

KathleenDollard commented 2 months ago

Annotation accessors were initially envisioned as a single widely used struct. But since it serves as the pipeline between the data provider and the CLI author, it would be desirable to expand its use. Since it is, and should probably remain, a struct this means we are using the annotation pattern in other scenarios. These variations are in the signature and overloads of Set and TryGet.

While this would add complexity to the subsystems, it would allow annotation accessor usage to be tailored for CLI author convenience.

The proposal is to embrace annotation accessors as a pattern, rather than a single class. Examples are the ValueAnnotationAccessor and ValueFuncAnnotationAccessor in #2413.

Some examples:

Parameter type checking:

Multiple overloads

Additional methods

Custom behavior