File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
9
9
# ======================================================================================================================
10
10
11
11
# 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 )
13
13
14
14
# settings
15
15
set (Target "modbus-rtu-client-shm" ) # Executable name (without file extension!)
Original file line number Diff line number Diff line change 19
19
#include < sysexits.h>
20
20
#include < unistd.h>
21
21
22
- // ! Help output line width
23
- static constexpr std::size_t HELP_WIDTH = 120 ;
24
-
25
22
// ! Max number of modbus registers
26
23
static constexpr std::size_t MAX_MODBUS_REGISTERS = 0x10000 ;
27
24
@@ -161,7 +158,15 @@ int main(int argc, char **argv) {
161
158
162
159
// print usage
163
160
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
+ }
165
170
#ifdef OS_LINUX
166
171
if (isatty (STDIN_FILENO)) {
167
172
struct winsize w {};
@@ -191,16 +196,6 @@ int main(int argc, char **argv) {
191
196
}
192
197
193
198
// 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
-
204
199
if (args.count (" shortversion" )) {
205
200
std::cout << PROJECT_VERSION << ' \n ' ;
206
201
return EX_OK;
You can’t perform that action at this time.
0 commit comments