-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Help messages correctly formatted (79 chars) #5749
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
Conversation
|
There will a war about the width of the terminal... 80, 132, ... |
|
Concept ACK |
src/bitcoin-cli.cpp
Outdated
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.
Let's use type-safe constants and inline functions. I'd like to avoid C-style macros unless there is no other choice. e.g.
static const int screenWidth = 132;
....
static inline std::string opt(const std::string &option, const std::string &message)
{
return option + FormatParagraph(...) + "\n";
}
|
Indeed, 79 or 80 are the only reasonable const widths I think. I suggest using COLUMNS environment var when defined, detecting it, and finally failing back to unformatted. |
|
Travis fails with: init.cpp:323:17: error: expected ‘)’ before ‘_’ |
|
OK - let's behave like adults here and NOT have an argument about what width to use. The code is general enough to work with any width. Let's first get it right, then later (as in, in a later pull) it can be improved to e.g. detect the screen width. |
|
I also see this as a improvement. conceptual ACK. |
|
@paveljanik @luke-jr @laanwj @jonasschnelli I looked at well known projects to better understand what is the standard. I found that 79 chars is considered the standard. And it does not change if COLUMNS changes, nor if xterm changes. Our problem is that the descriptions are long and do not fit in the screen together with the option. Thus I will put the description on the next line of the option. An example follows. |
|
@lucayepa Thanks for investigation. Looks good! |
|
Just tested this on OSX 10.10.3 and Windows 7. Binaries to test are here: |
|
@jonasschnelli IIUIC, "Thus I will put the description on the next line of the option." is not yet implemented. |
|
New style of options help looks good to me. |
|
The screenshot shows a different situation from the code. If you're working on reworking this and it shouldn't be merged as-is, can you please close the pull in the mean time? |
|
@jonasschnelli @laanwj @paveljanik In fact it was still not implemented. Now it is. Please test it with Windows and OsX. |
|
Please squash the commits to one so it can be compared in the Github UI to the master code. I like this approach. Can we get rid of the spaces in the option description? E.g.: strUsage += HelpMessageOpt("delin=N ", _("Delete input N from TX"));The spaces after In arguments to strUsage = HelpMessageGroup(_("Register Commands:"));can you delete double colons and add it back in the formatting function itself? It will touch the translation string, but that can be easily fixed in any decent localization tool (fuzzy matching). |
|
@paveljanik I removed the spaces. The idea is not to touch the translation, thus I did not touch the ':'. Maybe there should be a policy about when to touch the translation (at the start of a new version, or something like that). |
cbe5b40 to
52fa095
Compare
|
@paveljanik I squashed the 6 commits in a single one. |
|
Screenshot looks very good to me.
Meh. It is consistent with bitcoin-cli's output. Except that bitcoind happens to have only one invocation mode. |
|
@fanquake that doesn't look like the most recent version of this code, option and text are still on the same line there |
|
@laanwj Right, forgot the merge script doesn't actually build after merging. Change look fine now. Although there's still the issue with bitcoin-qt. |
|
@laanwj @fanquake @zander The issue about bitcoin-qt not displaying the help message, seems to be there since commit e179eb3. If you agree, I think that the right workflow should be to revert e179eb3, if possible, and then I will rebase my commit and try to fix the qt help message. Then I think it should be better to use only the function HelpMessage in src/init.cpp, since HelpMessageDialog::HelpMessageDialog already call HelpMessage. So I will try to delegate the output of the last part of the QT help message to HelpMessage. But first solve the bug intorduced by e179eb3. |
|
wow, I only heard now for the first time my commit caused a regressions. Not nice to wake up to the suggestion to get it reverted. Please give me a chance to understand the issue before you revert anything. |
|
@lucayepa to say that my commit (e179eb3) introduced a bug is not really true. It does the best it can with unstructured data. With your change in the unstructured data it no longer works. Maybe the best solution is to make the data actually structured. Which means that instead of building a large string in the core and then using heuristics to split stuff again in the GUI (so it can be put in a table), we both work on structured data. My suggestion; change HelpMessageCli() to return something like; then instead of calling HelpMessageOpt inside the HelpMessageCli() method, you move it to the place where HelpMessageCli() is called. This removes the magic heuristics requirement in the GUI and would make it trivial to fix (I can help) the GUI dialog. |
|
Well in any case if that was already broken beforehand, it is not the responsibility of this pull to fix it. Seemingly no one tested So the only thing here that remains to be fixed is the help message dialog, which now shows the output in two styles. |
|
@jtimon util.cpp seems the appropriate place due to their link with other option management functions which are there too. Is there any reason you need to use these functions and not Get*Arg? |
|
@jtimon @laanwj @luke-jr @theuni As suggested, I left the new functions in util.h @zander @laanwj @fanquake I resolved the bug from e179eb3 . Now "bitcoin-qt -help" returns the correct output. @paveljanik @jonasschnelli I put all the options in a single place (init.cpp). There were already other options qt-related in init.cpp. Having all the options in a single place seems far more clean. This resolve the wrong format for UI options too. As in e179eb3, the QT help message does not have a scroll bar. |
Help messages are formatted programmatically with FormatParagraph in order not to break existing strings in Transifex. The new format works even if the translation of the strings modifies the lenght of the message. Sqashed 6 commits in a single one. Help messages correctly formatted for SVGA text mode (132 chars) Help messages are formatted programmatically with FormatParagraph in order not to break existing strings in Transifex. The new format should work even if the translation of the strings modifies the lenght of the message. Fix - syntax error Correct formatting for 79 chars Correctly based on C++ functions Removed spare spaces from option strings Fix - syntax error
. Closes the bug from commit e179eb3 ("bitcoin-qt -help" did not show any message) . Move all the options in init.cpp (there were already some options related to bitcoin-qt)
e9536cc to
f754707
Compare
|
rebased |





Help messages are formatted programmatically with FormatParagraph in order not to break existing strings in Transifex (hint in #5734).
The new format should work even if the translation of the strings modifies the lenght of the message.