Skip to content

Commit 37ab117

Browse files
committed
Merge #13872: [docs] Reformat -help output for help2man
7272fdc [docs] Reformat -help output for help2man (Tim Ruffing) Pull request description: This commit slightly changes the format of the "Usage" strings in CLI `-help` messages to meet the expection of the help2man tool, which we use to generate man pages. On the way, we remove a few calls to `strprintf()`, which became superficial after commit 32fbfda. Before: ![screenshot from 2018-08-04 12-11-25](https://user-images.githubusercontent.com/1071625/43675564-6e2e016c-97e2-11e8-8de7-0912a4088efd.png) After: ![screenshot from 2018-08-04 12-11-46](https://user-images.githubusercontent.com/1071625/43675566-712d7032-97e2-11e8-85a7-5decc6dcb4b2.png) Tree-SHA512: 9752ee0d0fde0b084e00232609866291ff493f4feb45919279b0f142b04635c049ddd2bf71ff6ad57d4ae1ed37103348640d253bb4f0b3e16b7fd2bb4b2a6fba
2 parents 26f59f5 + 7272fdc commit 37ab117

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

src/bitcoin-cli.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,13 @@ static int AppInitRPC(int argc, char* argv[])
104104
return EXIT_FAILURE;
105105
}
106106
if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
107-
std::string strUsage = strprintf("%s RPC client version", PACKAGE_NAME) + " " + FormatFullVersion() + "\n";
107+
std::string strUsage = PACKAGE_NAME " RPC client version " + FormatFullVersion() + "\n";
108108
if (!gArgs.IsArgSet("-version")) {
109-
strUsage += "\nUsage:\n"
110-
" bitcoin-cli [options] <command> [params] " + strprintf("Send command to %s", PACKAGE_NAME) + "\n" +
111-
" bitcoin-cli [options] -named <command> [name=value] ... " + strprintf("Send command to %s (with named arguments)", PACKAGE_NAME) + "\n" +
112-
" bitcoin-cli [options] help List commands\n" +
113-
" bitcoin-cli [options] help <command> Get help for a command\n";
114-
109+
strUsage += "\n"
110+
"Usage: bitcoin-cli [options] <command> [params] Send command to " PACKAGE_NAME "\n"
111+
"or: bitcoin-cli [options] -named <command> [name=value]... Send command to " PACKAGE_NAME " (with named arguments)\n"
112+
"or: bitcoin-cli [options] help List commands\n"
113+
"or: bitcoin-cli [options] help <command> Get help for a command\n";
115114
strUsage += "\n" + gArgs.GetHelpMessage();
116115
}
117116

src/bitcoin-tx.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ static int AppInitRawTx(int argc, char* argv[])
9898

9999
if (argc < 2 || HelpRequested(gArgs)) {
100100
// First part of help message is specific to this utility
101-
std::string strUsage = strprintf("%s bitcoin-tx utility version", PACKAGE_NAME) + " " + FormatFullVersion() + "\n\n" +
102-
"Usage:\n"
103-
" bitcoin-tx [options] <hex-tx> [commands] Update hex-encoded bitcoin transaction\n" +
104-
" bitcoin-tx [options] -create [commands] Create hex-encoded bitcoin transaction\n" +
105-
"\n";
101+
std::string strUsage = PACKAGE_NAME " bitcoin-tx utility version " + FormatFullVersion() + "\n\n" +
102+
"Usage: bitcoin-tx [options] <hex-tx> [commands] Update hex-encoded bitcoin transaction\n" +
103+
"or: bitcoin-tx [options] -create [commands] Create hex-encoded bitcoin transaction\n" +
104+
"\n";
106105
strUsage += gArgs.GetHelpMessage();
107106

108107
fprintf(stdout, "%s", strUsage.c_str());

src/bitcoind.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,15 @@ static bool AppInit(int argc, char* argv[])
7171

7272
// Process help and version before taking care about datadir
7373
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
74-
std::string strUsage = strprintf("%s Daemon", PACKAGE_NAME) + " version " + FormatFullVersion() + "\n";
74+
std::string strUsage = PACKAGE_NAME " Daemon version " + FormatFullVersion() + "\n";
7575

7676
if (gArgs.IsArgSet("-version"))
7777
{
7878
strUsage += FormatParagraph(LicenseInfo());
7979
}
8080
else
8181
{
82-
strUsage += "\nUsage:\n"
83-
" bitcoind [options] " + strprintf("Start %s Daemon", PACKAGE_NAME) + "\n";
84-
82+
strUsage += "\nUsage: bitcoind [options] Start " PACKAGE_NAME " Daemon\n";
8583
strUsage += "\n" + gArgs.GetHelpMessage();
8684
}
8785

src/qt/utilitydialog.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ HelpMessageDialog::HelpMessageDialog(interfaces::Node& node, QWidget *parent, bo
7070
ui->helpMessage->setVisible(false);
7171
} else {
7272
setWindowTitle(tr("Command-line options"));
73-
QString header = "Usage:\n"
74-
" bitcoin-qt [command-line options] \n";
73+
QString header = "Usage: bitcoin-qt [command-line options] \n";
7574
QTextCursor cursor(ui->helpMessage->document());
7675
cursor.insertText(version);
7776
cursor.insertBlock();
@@ -80,7 +79,7 @@ HelpMessageDialog::HelpMessageDialog(interfaces::Node& node, QWidget *parent, bo
8079

8180
std::string strUsage = gArgs.GetHelpMessage();
8281
QString coreOptions = QString::fromStdString(strUsage);
83-
text = version + "\n" + header + "\n" + coreOptions;
82+
text = version + "\n\n" + header + "\n" + coreOptions;
8483

8584
QTextTableFormat tf;
8685
tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);

0 commit comments

Comments
 (0)