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: | 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!) diff --git a/src/main.cpp b/src/main.cpp index 87d8259..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'; @@ -60,16 +67,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;