Skip to content

Commit

Permalink
Merge pull request #13 from NikolasK-source/main
Browse files Browse the repository at this point in the history
update to 1.3.1
  • Loading branch information
NikolasK-source authored Apr 12, 2024
2 parents 2a71903 + d825920 commit 7dad5be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down
25 changes: 11 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
#include <cxxopts.hpp>
#include <filesystem>
#include <iostream>
#include <sys/ioctl.h>
#include <sysexits.h>

//! 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");
Expand Down Expand Up @@ -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<decltype(w.ws_col)>(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';
Expand All @@ -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;
Expand Down

0 comments on commit 7dad5be

Please sign in to comment.