Skip to content

Commit 9d6093a

Browse files
Merge pull request #23 from NikolasK-source/main
update to 0.4.1
2 parents 395ad9e + bd9058b commit 9d6093a

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
99
# ======================================================================================================================
1010

1111
# project
12-
project(Modbus_RTU_client_shm LANGUAGES CXX VERSION 0.4.0)
12+
project(Modbus_RTU_client_shm LANGUAGES CXX VERSION 0.4.1)
1313

1414
# settings
1515
set(Target "modbus-rtu-client-shm") # Executable name (without file extension!)

src/main.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#include <sysexits.h>
2020
#include <unistd.h>
2121

22-
//! Help output line width
23-
static constexpr std::size_t HELP_WIDTH = 120;
24-
2522
//! Max number of modbus registers
2623
static constexpr std::size_t MAX_MODBUS_REGISTERS = 0x10000;
2724

@@ -161,7 +158,15 @@ int main(int argc, char **argv) {
161158

162159
// print usage
163160
if (args.count("help")) {
164-
options.set_width(HELP_WIDTH);
161+
static constexpr std::size_t MIN_HELP_SIZE = 80;
162+
if (isatty(STDIN_FILENO)) {
163+
struct winsize w {};
164+
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1) { // NOLINT
165+
options.set_width(std::max(static_cast<decltype(w.ws_col)>(MIN_HELP_SIZE), w.ws_col));
166+
}
167+
} else {
168+
options.set_width(MIN_HELP_SIZE);
169+
}
165170
#ifdef OS_LINUX
166171
if (isatty(STDIN_FILENO)) {
167172
struct winsize w {};
@@ -191,16 +196,6 @@ int main(int argc, char **argv) {
191196
}
192197

193198
// print version
194-
if (args.count("longversion")) {
195-
std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << " (compiled with " << COMPILER_INFO << " on "
196-
<< SYSTEM_INFO << ')'
197-
#ifndef OS_LINUX
198-
<< "-nonlinux"
199-
#endif
200-
<< '\n';
201-
return EX_OK;
202-
}
203-
204199
if (args.count("shortversion")) {
205200
std::cout << PROJECT_VERSION << '\n';
206201
return EX_OK;

0 commit comments

Comments
 (0)