-
I have tried several ways, I can't seem to find it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The docopt format has no means of specifying the type of a positional or option argument therefore docopt.net doesn't support anything but string-based arguments at the fundamental level. This helps to keep the library simple, make it do one thing and try do it as well as possible. The moment you get into type conversion, you open a can of worms of expectations and the complexity explodes. The status of docopt.net is MVP for general utility. That doesn't mean such support cannot land in the future, but more on that later. Once the parsing is done into properties of the arguments class generated by the source generator, it is up to the application to do the conversion to other types. This can be done through computed properties on another partial definition of the arguments type or layering a view on top through a wrapper class that provides more type-safety for an application's own internal use. docopt.net does have some basic notion of an argument value kind: docopt.net/src/DocoptNet/ArgValue.cs Line 15 in cc1258e But it's not what you might have in mind. There's a detailed design document about the source generator design that's work-in-progress in PR #119. It explains currently implemented features and some thoughts about future extensions. There's a section on Types that explains how the source generator decides (today) the fundamental type of an argument per the docopt format:
So as you can see, an option will be typed as In the same document, there is a proposal about how type conversions could eventually be supported by the source generator, but this is not currently implemented. I have been using docopt.net in quite a few projects (see CSharpMinifier, for example) and so far, I haven't found a burning need for the source generator to support this; it's not itch I personally have that needs scratching. If someone wants to work on that, I'd be happy to entertain the idea. |
Beta Was this translation helpful? Give feedback.
The docopt format has no means of specifying the type of a positional or option argument therefore docopt.net doesn't support anything but string-based arguments at the fundamental level. This helps to keep the library simple, make it do one thing and try do it as well as possible. The moment you get into type conversion, you open a can of worms of expectations and the complexity explodes. The status of docopt.net is MVP for general utility. That doesn't mean such support cannot land in the future, but more on that later.
Once the parsing is done into properties of the arguments class generated by the source generator, it is up to the application to do the conversion to other types. This …