Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #225 +/- ##
=======================================
Coverage 91.90% 91.90%
=======================================
Files 17 17
Lines 1618 1618
=======================================
Hits 1487 1487
Misses 131 131 ☔ View full report in Codecov by Sentry. |
|
Alternative approach to try:
|
|
Virtual could work https://github.com/eseiler/sharg-parser/tree/misc/virtual_validator But it's not so nice, we need to use std::any and a validator needs to any_cast it to its option value type. |
|
Thanks for putting so much effort in improving the diagnostics. But in the end, this is a C++ problem and not something you need to feel responsible about. That having been said, I do think there is merit in type-erasing the validator and making the entire config a non-template, because it makes using and debugging it a lot simpler! ¹ If needed, one could mandate an additional edit: I forgot to say: if the parameter-type is fixed, there are multiple ways to implement this easily, e.g. virtual functions, |
Indeed, the only reason I see to do that is that it's the API and a very unhelpful error message
Yes, that would make it rather easy.
We can just validate each element of a range instead of the whole range at once. But this also depends on the parsing itself is solved.
Yep, the |
See #220
To-do
Forgot sharg::config?is a placeholderSummary
Improves error message when using
add_option/add_flag/add_positional_optionwithout an explicitsharg::config, e.g.sharg::parser parser{/* ... */}; parser.add_option(value, /* sharg::config */{.short_id = 'i', .long_id = "int", .description = "Int"});Pros:
Cons:
Most of the added code is to just check that both configs are in sync.
Since the 3 parser functions are the main API, it might be worth it to add some extra code that mitigates possible compiler errors. Though it should be rare to encounter this specific error if copy/pasting from the tutorial/snippets.
All in all, we need to weigh pros and cons.
Error message before
Error message after