From 1a9ef1264a52ab7c43b8bc95664ea9f91878bcd7 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Tue, 15 Aug 2023 15:52:31 +0000 Subject: [PATCH 1/2] Add version information for psinode and psitest --- .../common/include/psibase/version.hpp | 5 ++++ programs/psinode/main.cpp | 16 +++++++++++-- programs/psitest/main.cpp | 24 +++++++++++++++---- 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 libraries/psibase/common/include/psibase/version.hpp diff --git a/libraries/psibase/common/include/psibase/version.hpp b/libraries/psibase/common/include/psibase/version.hpp new file mode 100644 index 000000000..5c93bd1d4 --- /dev/null +++ b/libraries/psibase/common/include/psibase/version.hpp @@ -0,0 +1,5 @@ +#pragma once + +#define PSINODE_VERSION_MAJOR 0 +#define PSINODE_VERSION_MINOR 1 +#define PSINODE_VERSION_PATCH 6 diff --git a/programs/psinode/main.cpp b/programs/psinode/main.cpp index f4e839ce5..4d1509488 100644 --- a/programs/psinode/main.cpp +++ b/programs/psinode/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -445,7 +446,9 @@ struct transaction_queue } #define CATCH_IGNORE \ - catch (...) {} + catch (...) \ + { \ + } bool push_boot(BlockContext& bc, transaction_queue::entry& entry) { @@ -2070,6 +2073,7 @@ int main(int argc, char* argv[]) std::string tls_key; byte_size db_cache_size; byte_size db_size; + bool version; namespace po = boost::program_options; @@ -2109,6 +2113,7 @@ int main(int argc, char* argv[]) #endif opt("leeway", po::value(&leeway_us)->default_value(200000), "Transaction leeway, in µs."); + opt("version,V", po::bool_switch(&version), "Print version information"); desc.add(common_opts); opt = desc.add_options(); // Options that can only be specified on the command line @@ -2160,7 +2165,7 @@ int main(int argc, char* argv[]) } catch (std::exception& e) { - if (!vm.count("help")) + if (!vm.count("help") && !vm.count("version")) { std::cerr << e.what() << "\n"; return 1; @@ -2174,6 +2179,13 @@ int main(int argc, char* argv[]) return 1; } + if (version) + { + std::cerr << "psinode " << PSINODE_VERSION_MAJOR << "." << PSINODE_VERSION_MINOR << "." + << PSINODE_VERSION_PATCH << "\n"; + return 1; + } + try { psibase::loggers::set_path(db_path); diff --git a/programs/psitest/main.cpp b/programs/psitest/main.cpp index 18502e5ec..81b9fc4ef 100644 --- a/programs/psitest/main.cpp +++ b/programs/psitest/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -1001,6 +1002,10 @@ const char help[] = R"( Show this message + -V, --version + + Print version information + -v, --verbose Show detailed logging @@ -1018,16 +1023,17 @@ const char help[] = R"( other constraints on debug.wasm. psibase still enforces constraints on service.wasm. (repeatable) - --timing + --timing - Show how long transactions take in us. + Show how long transactions take in µs. )"; int main(int argc, char* argv[]) { - bool show_usage = false; - bool error = false; - int verbose = 0; + bool show_usage = false; + bool error = false; + bool show_version = false; + int verbose = 0; Loggers logConfig; std::map substitutions; cl_flags_t additional_args; @@ -1037,6 +1043,8 @@ int main(int argc, char* argv[]) { if (!strcmp(argv[next_arg], "-h") || !strcmp(argv[next_arg], "--help")) show_usage = true; + else if (!strcmp(argv[next_arg], "-V") || !strcmp(argv[next_arg], "--version")) + show_version = true; else if (!strcmp(argv[next_arg], "-v") || !strcmp(argv[next_arg], "--verbose")) { ++verbose; @@ -1082,6 +1090,12 @@ int main(int argc, char* argv[]) } if (next_arg >= argc) error = true; + if (show_version) + { + std::cerr << "psitest " << PSINODE_VERSION_MAJOR << "." << PSINODE_VERSION_MINOR << "." + << PSINODE_VERSION_PATCH << "\n"; + return 0; + } if (show_usage || error) { std::cerr << usage; From d6309bc6a78d4b6c0df7d61ad1d59c3964fbf7b8 Mon Sep 17 00:00:00 2001 From: James-Mart Date: Wed, 16 Aug 2023 01:24:17 +0000 Subject: [PATCH 2/2] pr feedback --- libraries/psibase/common/include/psibase/version.hpp | 6 +++--- programs/psinode/main.cpp | 4 ++-- programs/psitest/main.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/psibase/common/include/psibase/version.hpp b/libraries/psibase/common/include/psibase/version.hpp index 5c93bd1d4..1e4f5946f 100644 --- a/libraries/psibase/common/include/psibase/version.hpp +++ b/libraries/psibase/common/include/psibase/version.hpp @@ -1,5 +1,5 @@ #pragma once -#define PSINODE_VERSION_MAJOR 0 -#define PSINODE_VERSION_MINOR 1 -#define PSINODE_VERSION_PATCH 6 +#define PSIBASE_VERSION_MAJOR 0 +#define PSIBASE_VERSION_MINOR 1 +#define PSIBASE_VERSION_PATCH 6 diff --git a/programs/psinode/main.cpp b/programs/psinode/main.cpp index 4d1509488..a06d2b743 100644 --- a/programs/psinode/main.cpp +++ b/programs/psinode/main.cpp @@ -2181,8 +2181,8 @@ int main(int argc, char* argv[]) if (version) { - std::cerr << "psinode " << PSINODE_VERSION_MAJOR << "." << PSINODE_VERSION_MINOR << "." - << PSINODE_VERSION_PATCH << "\n"; + std::cerr << "psinode " << PSIBASE_VERSION_MAJOR << "." << PSIBASE_VERSION_MINOR << "." + << PSIBASE_VERSION_PATCH << "\n"; return 1; } diff --git a/programs/psitest/main.cpp b/programs/psitest/main.cpp index 81b9fc4ef..adc8dc639 100644 --- a/programs/psitest/main.cpp +++ b/programs/psitest/main.cpp @@ -1092,8 +1092,8 @@ int main(int argc, char* argv[]) error = true; if (show_version) { - std::cerr << "psitest " << PSINODE_VERSION_MAJOR << "." << PSINODE_VERSION_MINOR << "." - << PSINODE_VERSION_PATCH << "\n"; + std::cerr << "psitest " << PSIBASE_VERSION_MAJOR << "." << PSIBASE_VERSION_MINOR << "." + << PSIBASE_VERSION_PATCH << "\n"; return 0; } if (show_usage || error)