-
Notifications
You must be signed in to change notification settings - Fork 7
[FEATURE] Automatically open man page #173
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportBase: 92.29% // Head: 91.58% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #173 +/- ##
==========================================
- Coverage 92.29% 91.58% -0.72%
==========================================
Files 16 16
Lines 1440 1461 +21
==========================================
+ Hits 1329 1338 +9
- Misses 111 123 +12
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. |
Thanks for the quick PR! If you don't want to turn this on by default, can you add a nob in the parser, maybe just a |
So, like Another option could be to do to it via a definition |
yep, very straightforward and easy!
Warum einfach, wenns auch kompliziert geht? 🙃 |
I'll need to wrap everything in coverage-excludes anyway :D |
But with touching the preprocessor... Depending on build-system, this may or may not be easy. In any case, it is something I would only recommend as last resort. If a simple In any case, thanks for working on this! |
The problem with the There could be a second constructor that takes another argument. I wouldn't add a defaulted argument to the existing constructor because it would be hard to document what part is experimental and what part stable. |
Ah, I thought that all the logic happens on
Hm, yeah, having multiple, party defaulted arguments scales very badly. A config object like the other ones would have likely been better. Maybe that could be added with an extra constructor? Then you can also document the members of the struct individually. |
I think adding a config would be quite a big change to for implementing this feature. So, right now, I'd say we have two possibilities: Changing the constructorIt can't be an additional constructor (as long as we use the same arguments) because it would be ambiguous. parser(std::string const & app_name,
int const argc,
char const * const * const argv,
update_notifications version_updates = update_notifications::on,
std::vector<std::string> subcommands = {},
open_help_as_man = open_help_as_man::off) Adding a definitionFor example, via a CMake option. Something like Depending on how you look at it, it might be considered an overall (dis-)advantage to set it via the build system/compiler definition. The disadvantage is that doing it this way is a bit obscure. The advantage is that whoever builds an application can decide for themselves whether they want this behavior, without actually changing any code. In the other case, it would be a developer decision, like setting P.S.: We have a paper review deadline on March 16th, so we might be slower than usual :) |
Thank you for your work on this and the detailed comments. I was unaware that relevant logic (format selection) happens at construction. I don't know why it couldn't happen later? But I am sure there were good reasons for this. ¹ At the current state, I see three options, in descending preference:
Personally, I think 1. is great, and people will love it; it's a cool feature that everyone will experience immediately. It will not break any code, because any non-interactive use of the parser will trigger the old behaviour anyway. But I understand if you are reluctant about this. The second option looks like a bit more work, but I think it's actually a good future-proof change. I would do it as The third option is more of a band-aid, but something I could live with. Using a C macro is very undesirable from my point of view. It needs to be set before including the header, so the configuration of the parser becomes very "unlocal". A CMake option would be even worse, because then I need to move the configuration out of my C++ source code. Thank you in any case! ¹ On a very general note, maybe for a future version: I think it would have been preferable to separate "setup" of the parser (how it works, what it looks for) and "applying" the parser to user-provided arguments (i.e. using the parser). One way to do this would be to provide the |
I'm in favor of the config object because
While thinking about this, I propose the following constructor: sharg::parser p{argc,
argv,
sharg::parser::config{.notify_about_updates = true,
.subcommands = {"foo"},
.interactive_man_page = true}}; note: In my proposal the app name is not part of the constructor anymore. I notices that we can (currently!) also set the app name via This c-tor change could/would be a minor release, deprecating the other constructor. We could also think about a major release right away. |
👍 This probably means that we will add the config in another PR, and this PR then adds a new config element and implements the functionality. |
This looks very good! |
@@ -336,7 +336,7 @@ class version_checker | |||
// nor did the the cookie tell us what to do. We will now ask the user if possible or do the check by default. | |||
write_cookie("ASK"); // Ask again next time when we read the cookie, if this is not overwritten. | |||
|
|||
if (detail::is_terminal()) // LCOV_EXCL_START | |||
if (detail::input_is_terminal()) // LCOV_EXCL_START |
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.
also do the same for cerr
#170
Questions: