-
Notifications
You must be signed in to change notification settings - Fork 363
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
Support user defined delimiter when parsing list #209
Conversation
Codecov Report
@@ Coverage Diff @@
## master #209 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 12
Lines 1932 1933 +1
=====================================
+ Hits 1932 1933 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #209 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 12
Lines 1960 1964 +4
=====================================
+ Hits 1960 1964 +4
Continue to review full report at Codecov.
|
Please add a few tests, including at least the following cases:
I believe space will always be a separator, since this is what gets passed to CLI11 from argc, argv. |
I can fix the style pretty trivially if needed. Is there a version with defaults to add too? |
This should be added in the Option *add_option(std::string option_name,
std::vector<T> &variable, ///< The variable vector to set
std::string description,
bool defaulted) one too, right below, and matching tests copied and pasted in. |
i will update next week |
a214831
to
29ed0ae
Compare
@henryiii there are some style issues not related to my changes, besides that i think it's ok |
Okay, I'll rerun the formatter soon. |
Looks like the 5.0.1 version of clang-format is a bit finicky too. I'll play with cleanup tomorrow, and will probably add a couple of clang-format-off directives (or switch to a docker clang-format on Travis and use unibeatify's version). |
f659f88
to
434a247
Compare
This commit allows parsing any char separated list given by the user. E.g app -a 1,2,3 std::vector<int> params; app.add_option("-a", params, "Parse the params", ','); Signed-off-by: Rafi Wiener <rafiw@mellanox.com> add tests for delimiter parsing Signed-off-by: Rafi Wiener <rafiw@mellanox.com> Fixing style, adding docker version of clang-format
By the way, I believe the API will change a bit with #240: Instead of an extra argument in add_option, you would do it like this now: add_option("--thing", vector)->delimiter(','); As a bonus, the delimiter is now supported by validators and more. |
Currently user can only parse list with spaces
E.g app -o 1 2 3
now use can define his own one char delimiter e.g comma