From 950ecd6bbcc7e75e80b0d2a9dc11efec551d173b Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Mon, 17 Apr 2023 09:37:05 -0400 Subject: [PATCH] add `--version` --- docs/COMMAND_LINE.MD | 1 + src/main.cpp | 11 +++++++++++ src/util.h | 1 + 3 files changed, 13 insertions(+) diff --git a/docs/COMMAND_LINE.MD b/docs/COMMAND_LINE.MD index 293a37f..307f31f 100644 --- a/docs/COMMAND_LINE.MD +++ b/docs/COMMAND_LINE.MD @@ -29,6 +29,7 @@ --no-upnp Disable UPnP port forwarding --no-igd An alias for --no-upnp --upnp-stratum Port forward Stratum port (it's not forwarded by default) +--version Print p2pool's version and build details ``` ### Example command line diff --git a/src/main.cpp b/src/main.cpp index 78f9709..f5737a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,7 @@ void p2pool_usage() "--no-igd An alias for --no-upnp\n" "--upnp-stratum Port forward Stratum port (it's not forwarded by default)\n" #endif + "--version Print p2pool's version and build details\n" "--help Show this help message\n\n" "Example command line:\n\n" "%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n", @@ -75,6 +76,11 @@ void p2pool_usage() ); } +void p2pool_version() +{ + printf("P2Pool %s\n", p2pool::VERSION); +} + void memory_tracking_start(); void memory_tracking_stop(); @@ -90,6 +96,11 @@ int main(int argc, char* argv[]) p2pool_usage(); return 0; } + + if (strcmp(argv[i], "--version") || strcmp(argv[i], "/version") || strcmp(argv[i], "-v") || strcmp(argv[i], "/v")) { + p2pool_version(); + return 0; + } } memory_tracking_start(); diff --git a/src/util.h b/src/util.h index a8ad300..3072069 100644 --- a/src/util.h +++ b/src/util.h @@ -280,6 +280,7 @@ struct PerfTimer void memory_tracking_start(); void memory_tracking_stop(); void p2pool_usage(); +void p2pool_version(); namespace robin_hood {