-
Notifications
You must be signed in to change notification settings - Fork 7
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
[MISC] Defer everything to parse() #238
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
022ed36
to
7a0df7a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #238 +/- ##
==========================================
- Coverage 95.23% 95.13% -0.10%
==========================================
Files 18 18
Lines 1700 1728 +28
==========================================
+ Hits 1619 1644 +25
- Misses 81 84 +3 ☔ View full report in Codecov by Sentry. |
I like it :) |
56769fa
to
8ceaf6a
Compare
5bd40d2
to
077f5e7
Compare
Why not? E.g. |
I do think it should be allowed; why shouldn't it be :) But the code and documentation don't agree on what is allowed. If I recall correctly from the code, there's also some very weird behavior: Let's say I have a parser with
|
All of these should work in my opinion. |
077f5e7
to
5721c83
Compare
|
||
auto check_error = [&parser, &expected_message](char const * file, int line) | ||
{ | ||
::testing::ScopedTrace trace(file, line, "check_error"); |
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.
The output looks like this:
../../../../test/unit/parser/format_parse_test.cpp:701: Failure
Expected equality of these values:
expected_message
Which is: "[...]"
actual_message
Which is: "[...]"
With diff:
@@ -1,3 +1,2 @@
-[...]
-[...]
+[...]
Google Test trace:
../../../../test/unit/parser/format_parse_test.cpp:719: check_error
Without the trace, it would report line 701
, i.e., the EXPECT_EQ
in the lambda.
Not very helpful.
The trace adds the last part, which then correctly points to line 719
.
parser = /* ... */;
{
SCOPED_TRACE("test1");
check_error();
}
parser = /* ... */;
{
SCOPED_TRACE("test2");
check_error();
}
Would also work instead, but too many scopes for my test.
We might unify the check_error
thing at some point since we use it in multiple locations.
bce6cbb
to
8814396
Compare
54ba28a
to
745b321
Compare
auto parser = get_subcommand_parser({"-h"}, {"sub1", "sub2"}); | ||
parser.info.description.push_back("description"); | ||
parser.add_option(option_value, sharg::config{.short_id = 'f', .long_id = "foo", .description = "foo bar."}); |
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.
sorry, whats wrong here now? I remember you said it must be deleted but I forget and can't see why
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.
Originally because options are no longer allowed.
However, I now changed it to just use a flag
; and also changed The following options below
to The following options
745b321
to
0411c92
Compare
0411c92
to
868bf1a
Compare
868bf1a
to
d44ad98
Compare
parse()
parse()
init()
--export-helpXhtml
being accepted for anyX
Follow-up:
sharg::user_input_error
(verify_subcommand()
).I don't think it's necessary. It might be hard to differentiate between options/flags for the top-level-parser and a potentially misspelled subcommand.
./app -o foo
, wherefoo
is a subcommand and-o
is either a flag or an optionCommit 3Deferred: Do we want something like astd::monostate
for the format variant?¹ To get rid of thespecial_format_was_set
, I could also just use any non-special-format as default for the variant. Butformat_empty
might be more expressive and help to detect errors.¹ Can't use
std::monostate
directly because thevisit
call needs to be valid for all possible variants.