Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 1.3.1 #13

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading