-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does the Options attribute class really need to be sealed? #859
Comments
The core code of the parser is only looking for "OptionsAttribute" not "LogFileOptionAttribute" types... Submit a pull request with some initial work to enable this feature and we would consider it. |
I think reflection looking for an attribute will/can get derived classes of that attribute as well, but this is clearly on me to demonstrate. Will dig in. |
I finally got around to digging in, and after making literally one change - remove The current code does in fact look for derived types because in In any case, using (say) This also works, surprisingly, when The I'm doing my dev in Visual Studio 2022, with a large suite of C# .NET 6 code, and I compiled the CommandLine stuff with Overall, it all Just Works(tm), and I haven't found a downside or gotcha yet. I'm going to keep using this for a little while to shake it out, then will see if I can figure out how to make a pull request to make it so. |
I have been using CommandLineParser for a while now (and it's changed how I build tools -- thank you!) including in a program with ~50 Verbs (and growing), and since many of the Verbs take common options, I was hoping to extend
Options
to provide common handling of them.Simple example: if 15 Verbs take a
LogFile
option, each of which has a long name ("log-file") and a help description, I can do this now by constant strings to keep them consistent, but if I were able to do:and then adorn the actual option with:
I have easily a dozen of these common options. It's not a huge deal to create constant strings:
but adding this level of abstraction would be more convenient.
If there's a good reason for this class to be sealed, then so be it, but mine doesn't feel like a ridiculous use case. I may well get to 100 verbs for this tool by the time I'm done.
The text was updated successfully, but these errors were encountered: