From 14734f91f3c23e351425c40a385d99b8472e4286 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Mon, 1 Apr 2024 20:41:20 +0200 Subject: [PATCH 1/4] use more recent cxxopts --- .github/workflows/cmake.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6eea3bb..b2e52a4 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -26,7 +26,13 @@ jobs: - name: install cxxopts run: | - sudo apt install libcxxopts-dev + git clone https://github.com/jarro2783/cxxopts.git tmp/cxxopts + cd tmp/cxxopts + git checkout $(git tag | grep -P '^v\d+\.\d+\.\d+$' | sort | tail -1) + cmake -B build . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF -DCLANG_TIDY=OFF + cmake --build build + sudo cmake --install build + cd - - name: install cxxshm run: | From c76f35a5dac930325da91ec5d644330f7f8254a8 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Mon, 1 Apr 2024 20:41:31 +0200 Subject: [PATCH 2/4] remove duplicate 'longversion' --- src/main.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 87d8259..4b85bba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -60,16 +60,6 @@ int main(int argc, char **argv) { } // print version - if (opts.count("longversion")) { - std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << " (compiled with " << COMPILER_INFO << " on " - << SYSTEM_INFO << ')' -#ifndef OS_LINUX - << "-nonlinux" -#endif - << '\n'; - return EX_OK; - } - if (opts.count("shortversion")) { std::cout << PROJECT_VERSION << '\n'; return EX_OK; From 30c3d6ac08fdde0c8c7f1d50c6ab1c948ec8d4d8 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Fri, 12 Apr 2024 21:42:07 +0200 Subject: [PATCH 3/4] determine help width from tty size --- src/main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4b85bba..4f4512a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,11 +11,9 @@ #include #include #include +#include #include -//! Help output line width -static constexpr std::size_t HELP_WIDTH = 120; - int main(int argc, char **argv) { const std::string exe_name = std::filesystem::path(*argv).filename().string(); cxxopts::Options options(exe_name, "Dump the content of a shared memory to stdout"); @@ -49,7 +47,16 @@ int main(int argc, char **argv) { } if (opts.count("help")) { - options.set_width(HELP_WIDTH); + static constexpr std::size_t MIN_HELP_SIZE = 80; + if (isatty(STDIN_FILENO)) { + struct winsize w {}; + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1) { // NOLINT + options.set_width(std::max(static_cast(MIN_HELP_SIZE), w.ws_col)); + } + } else { + options.set_width(MIN_HELP_SIZE); + } + std::cout << options.help() << '\n'; std::cout << '\n'; std::cout << "This application uses the following libraries:" << '\n'; From d825920ef6f04d358b6dd5b06705fc2c71e8ebd0 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Fri, 12 Apr 2024 21:49:36 +0200 Subject: [PATCH 4/4] increment version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d5129e..eb3d525 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.22.0 FATAL_ERROR) # ====================================================================================================================== # project -project(dump-shm LANGUAGES CXX VERSION 1.3.0) +project(dump-shm LANGUAGES CXX VERSION 1.3.1) # settings set(Target "dump-shm") # Executable name (without file extension!)