-
Notifications
You must be signed in to change notification settings - Fork 7
[FIX] is_option_set: match both long and short ids #226
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
Conversation
13e5d42 to
76357e3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
==========================================
+ Coverage 94.62% 94.75% +0.12%
==========================================
Files 18 19 +1
Lines 1730 1772 +42
Branches 46 47 +1
==========================================
+ Hits 1637 1679 +42
Misses 93 93 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
76357e3 to
1e9e8a4
Compare
smehringer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm in favour of this change, even if its an API break (right?)
Shouldn't break API as all the ID handling is internal. It does change the API in the sense that the behavior is fixed :D |
Yeah I guess :) I try to think about cases where people deliberately distinguish between short and long id.. but I can't find an actual use case. |
1e9e8a4 to
e58a7f4
Compare
1426353 to
13800ef
Compare
13800ef to
c61c23b
Compare
c745213 to
ee41f28
Compare
a11439e to
c1d0aea
Compare
c1d0aea to
85b7f75
Compare
|
Documentation preview available at https://docs.seqan.de/preview/seqan/sharg-parser/226 |
| EXPECT_THROW(parser.is_option_set("foo"), sharg::design_error); | ||
|
|
||
| EXPECT_NO_THROW(parser.parse()); | ||
| EXPECT_EQ(positional_options.size(), 2u); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is not given, the following 2 lines might be invalid accesses.
| EXPECT_EQ(positional_options.size(), 2u); | |
| ASSERT_EQ(positional_options.size(), 2u); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went for EXPECT_EQ(positional_options, (std::vector<std::string>{"--loo", "--bar"}));
85b7f75 to
d403d0d
Compare
d403d0d to
6ea2963
Compare
To-do
Problem
sharg::parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_value, sharg::config{.short_id = 'b', .long_id = "bar"}); parser.add_option(option_value, sharg::config{.short_id = 'l', .long_id = "loo"}); parser.add_option(option_value, sharg::config{.short_id = 'f', .long_id = "foobar"});When calling
./parser_test -b blah:This is quite unintuitive and has already caused me trouble.
A workaround is of course
But this relies on the user to get the short/long ID pairing correct.
Solution
Store short/long ID as a pair. When calling
is_option_set, we can search for both short and long ID.