-
Notifications
You must be signed in to change notification settings - Fork 344
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
Unicode API rework #923
Unicode API rework #923
Conversation
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
@henryiii PTAL. Implemented this before your comment about axing |
I was thinking this: int main(int argc, char** argv) {
CLI::App app{"App description"};
argv = app.ensure_utf8(argc, argv);
CLI11_PARSE(app);
return 0;
} That is, calling The downside is it's not as obvious how inject modification of argv in this form, of course. These are the possible usages: // 1
app.ensure_utf8(argc, argv);
CLI11_PARSE(app); // Uses stored argv vector on all platforms
// 2
argv = app.ensure_utf8(argc, argv);
CLI11_PARSE(app, argc, argv); // Uses produced argv vector
// 3
CLI11_PARSE(app, argc, argv); // Not unicode
// 4
CLI11_PARSE(app); // Not portable, but unicode My favorite probably is 2, as it's explicit, but 1 is pretty simple looking for most users who don't manipulate argv first, and can be written as 2 if a user does need to. I'm fine to drop 4 as too magical and not portable, but if we keep |
This looks like an improvement, my main question is, would it make sense to support (1) above and maybe drop (4)? (In later PRs) |
@phlptp thoughts about API in follow-ups? I’ll approve this PR tomorrow. |
I don't have any strong opinions on the unicode stuff, so this seems reasonable to me. |
Thanks for the merge! Would you mind putting in a word with the all-contributors bot about my contributions? Sorry for being indiscreet. |
@all-contributors, please add @andreasxp for code |
(Not totally sure the bot is still working, we might need to update manually, feel free to ping (a lot) if we forget!) |
Done in #977. |
Fixes #845 as discussed.
Comparing the two approaches of getting
argv
:CLI::argv()
:✔️ Works automatically and almost everywhere
❌ Small abstraction overhead on macOS
❌ Does not work in weird edge-cases such as missing
/proc
app.ensure_utf8
:✔️ True zero-overhead abstraction: you don't pay for what you don't use
✔️ Less moving parts than the "old" approach, probably can't be broken
❌ Requires extra code to be written by the user (which is sad because ideally everyone should use this by default)