File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 43
43
// ! Maximum number of registers per type
44
44
static constexpr size_t MODBUS_MAX_REGS = 0x10000 ;
45
45
46
- // ! Help output line width
47
- static constexpr std::size_t HELP_WIDTH = 120 ;
48
-
49
46
// ! Default permissions for the created shared memory
50
47
static constexpr mode_t DEFAULT_SHM_PERMISSIONS = 0660 ;
51
48
@@ -200,7 +197,15 @@ int main(int argc, char **argv) {
200
197
201
198
// print usage
202
199
if (args.count (" help" )) {
203
- options.set_width (HELP_WIDTH);
200
+ static constexpr std::size_t MIN_HELP_SIZE = 80 ;
201
+ if (isatty (STDIN_FILENO)) {
202
+ struct winsize w {};
203
+ if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &w) != -1 ) { // NOLINT
204
+ options.set_width (std::max (static_cast <decltype (w.ws_col )>(MIN_HELP_SIZE), w.ws_col ));
205
+ }
206
+ } else {
207
+ options.set_width (MIN_HELP_SIZE);
208
+ }
204
209
#ifdef OS_LINUX
205
210
if (isatty (STDIN_FILENO)) {
206
211
struct winsize w {};
You can’t perform that action at this time.
0 commit comments