diff --git a/libraries/psibase/common/include/psibase/version.hpp b/libraries/psibase/common/include/psibase/version.hpp new file mode 100644 index 000000000..1e4f5946f --- /dev/null +++ b/libraries/psibase/common/include/psibase/version.hpp @@ -0,0 +1,5 @@ +#pragma once + +#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 f4e839ce5..a06d2b743 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 " << PSIBASE_VERSION_MAJOR << "." << PSIBASE_VERSION_MINOR << "." + << PSIBASE_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..adc8dc639 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 " << PSIBASE_VERSION_MAJOR << "." << PSIBASE_VERSION_MINOR << "." + << PSIBASE_VERSION_PATCH << "\n"; + return 0; + } if (show_usage || error) { std::cerr << usage;