-
Notifications
You must be signed in to change notification settings - Fork 354
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
feat: unicode support #804
Conversation
8df6899
to
0974481
Compare
Codecov ReportBase: 99.45% // Head: 99.45% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #804 +/- ##
=======================================
Coverage 99.45% 99.45%
=======================================
Files 16 18 +2
Lines 4019 4069 +50
=======================================
+ Hits 3997 4047 +50
Misses 22 22
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There are Codacy reports which I disagree with but don't have permissions to ignore. Ready for review. |
for codacy you might be able to to put //NOLINTNEXTLINE on a few depending on the exact tool that is triggering them. |
One of the "2 workflows awaiting approval" which someone approved on f7e8901 was a github action "cmake config check", which failed because apparently Anyway, since this looks like a cmake bug, I modified github actions to run cmake versions on "appropriate" ubuntu distributions: cmake 3.4~3.10 on ubuntu 18.04, cmake 3.10~3.16 on ubuntu 20.04, and everything newer on ubuntu 22.04. Let me know if this is an ok solution. I ran cmake config tests on my fork, so they should be good to go. Feel free to approve the remaining workflows again, I'm excited to merge this soon 😅 |
This was also fixed in #813, so once that is merged and this branch updated it should be good as well. |
Looks like coverage failed (even though it succeeded earlier with the same code). In the meantime, I was going to suggest just letting coverage fall, but then I found out that |
I noticed the codecov thing as well, not entirely sure what changed but I think that is resolved in #813 as well. Waiting for @henryiii to review that one, then I think that can be merged and you can rebase this one. This PR is something I want @henryiii to review and approve since it is a pretty big change. |
Merged that one. Won't have time to review this till early next week, though. |
Re-ran checks after CI had unrelated third-party connection errors. |
include/CLI/Config.hpp
Outdated
@@ -14,7 +14,7 @@ | |||
#include <string> | |||
#include <utility> | |||
#include <vector> | |||
// [CLI11:public_includes:set] | |||
// [CLI11:public_includes:end] |
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.
Wait, why did this work before, actually? It should search to the first "end", which I would have thought would have created a broken single header include. Testing locally, it does look like it just causes #include <cctype>
to be missing; I guess this is included through something else so that's why it still works.
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.
After a brief look at the single header script, it seems that the multiline regex for collecting headers needs both "set" and "end" comments. So it just didn't match and by lucky coincidence the necessary headers were included elsewhere.
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
0f53c53
to
4f13fad
Compare
I wrote a longer reply yesterday but lost it when switching around. TL;DWA (too long; didn't write again): I think the design decisions are reasonable, I like the argument-less form (looks like Python's argparse), and keeping the cost low for projects that don't care about unicode. |
Thanks for your feedback. Does that mean this PR is ready to merge now? |
Yes, I think we can put it in, and let it sit for a while. I'm hoping this doesn't affect weird/niche systems negatively by including something they don't have, especially if they aren't using it. But maybe the best way to find out is to see if it breaks anyone in main for a bit. |
@henryiii Support for |
Fixes #14 as discussed.
Some notes:
argc
andargv
in favor of GetCommandLineW, becauseargv
passed in toparse
may have been already modified. Instead, I figured out a way to retrieve "original"argv
on other systems and made a parallel interface:app.parse(argc, argv)
stays the same andapp.parse()
uses "original as launched" args.argc()
andargv()
on all systems for "original" args.widen
andnarrow
in case the user uses a wide-string API with our UTF-8 string.to_path
on all systems which creates afilesystem::path
, widening the string on Windows.app.parse(CLI::system_args)
instead ofapp.parse()
, whereCLI::system_args
is value of a tag typeCLI::system_args_t
(feel free to suggest a better name for the tag)argc()
andargv()
as a global variable before main. This is already being done for macOS. Would improve syntax from (e.g. fromCLI::argv()[1]
toCLI::argv[1]
). Would remove any performance costs during main but will push them on users who don't care about Unicode or convert Unicode themselves.build/include_subdir
from cpplint just to catch actual warnings in terminal.Also, I made some benchmarks to measure the performance impact of supporting Unicode, since this was a concern. Measuring with google benchmark, all benchmarks receive
<program-name> --option1 1234 --option2 "hello world"
as commandline:CLI::App
, options, and parse the old way. Just for reference when judging performance.CLI::argv()
(without caching into a static variable)app.parse(argc, argv)
, i.e. old speedapp.parse()
, i.e. new speedWindows:
get_global_args
andparse_normal
being the same time is a little sus, I suspect that maybe there are some optimizations in the benchmark loop which I failed to prevent.Linux:
Overall, for a function called once in the application, I think +2μs of time for Unicode support is acceptable.