Skip to content

Commit b5e93f8

Browse files
committed
doc: Add manual page generation for bitcoin-util
- Add `-version` option to `bitcoin-util` - Add `bitcoin-util` call to `gen-manpages.sh` - Add stub manual page `bitcoin-util.1` - Add install of `bitcoin-util.1` to build system
1 parent 7b97563 commit b5e93f8

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

contrib/devtools/gen-manpages.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ BITCOIND=${BITCOIND:-$BINDIR/bitcoind}
1414
BITCOINCLI=${BITCOINCLI:-$BINDIR/bitcoin-cli}
1515
BITCOINTX=${BITCOINTX:-$BINDIR/bitcoin-tx}
1616
WALLET_TOOL=${WALLET_TOOL:-$BINDIR/bitcoin-wallet}
17+
BITCOINUTIL=${BITCOINQT:-$BINDIR/bitcoin-util}
1718
BITCOINQT=${BITCOINQT:-$BINDIR/qt/bitcoin-qt}
1819

1920
[ ! -x $BITCOIND ] && echo "$BITCOIND not found or not executable." && exit 1
2021

2122
# Don't allow man pages to be generated for binaries built from a dirty tree
2223
DIRTY=""
23-
for cmd in $BITCOIND $BITCOINCLI $BITCOINTX $WALLET_TOOL $BITCOINQT; do
24+
for cmd in $BITCOIND $BITCOINCLI $BITCOINTX $WALLET_TOOL $BITCOINUTIL $BITCOINQT; do
2425
VERSION_OUTPUT=$($cmd --version)
2526
if [[ $VERSION_OUTPUT == *"dirty"* ]]; then
2627
DIRTY="${DIRTY}${cmd}\n"
@@ -43,7 +44,7 @@ read -r -a BTCVER <<< "$($BITCOINCLI --version | head -n1 | awk -F'[ -]' '{ prin
4344
echo "[COPYRIGHT]" > footer.h2m
4445
$BITCOIND --version | sed -n '1!p' >> footer.h2m
4546

46-
for cmd in $BITCOIND $BITCOINCLI $BITCOINTX $WALLET_TOOL $BITCOINQT; do
47+
for cmd in $BITCOIND $BITCOINCLI $BITCOINTX $WALLET_TOOL $BITCOINUTIL $BITCOINQT; do
4748
cmdname="${cmd##*/}"
4849
help2man -N --version-string=${BTCVER[0]} --include=footer.h2m -o ${MANDIR}/${cmdname}.1 ${cmd}
4950
sed -i "s/\\\-${BTCVER[1]}//g" ${MANDIR}/${cmdname}.1

doc/man/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ if BUILD_BITCOIN_TX
1616
dist_man1_MANS+=bitcoin-tx.1
1717
endif
1818

19+
if BUILD_BITCOIN_UTIL
20+
dist_man1_MANS+=bitcoin-util.1
21+
endif
22+
1923
if ENABLE_WALLET
2024
if BUILD_BITCOIN_WALLET
2125
dist_man1_MANS+=bitcoin-wallet.1

doc/man/bitcoin-util.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.TH BITCOIN-UTIL "1"
2+
.SH NAME
3+
bitcoin-util \- manual page for bitcoin-util
4+
5+
This is a placefolder file. Please follow the instructions in \fIcontrib/devtools/README.md\fR to generate the manual pages after a release.

src/bitcoin-util.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ static void SetupBitcoinUtilArgs(ArgsManager &argsman)
4040
{
4141
SetupHelpOptions(argsman);
4242

43+
argsman.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
44+
4345
SetupChainParamsBaseOptions(argsman);
4446
}
4547

@@ -62,12 +64,14 @@ static int AppInitUtil(int argc, char* argv[])
6264
return EXIT_FAILURE;
6365
}
6466

65-
if (argc < 2 || HelpRequested(gArgs)) {
67+
if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
6668
// First part of help message is specific to this utility
67-
std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n\n" +
68-
"Usage: bitcoin-util [options] [commands] Do stuff\n" +
69-
"\n";
70-
strUsage += gArgs.GetHelpMessage();
69+
std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n";
70+
if (!gArgs.IsArgSet("-version")) {
71+
strUsage += "\n"
72+
"Usage: bitcoin-util [options] [commands] Do stuff\n";
73+
strUsage += "\n" + gArgs.GetHelpMessage();
74+
}
7175

7276
tfm::format(std::cout, "%s", strUsage);
7377

0 commit comments

Comments
 (0)