mikesart / inotify-info

Linux inotify info reporting app
MIT License
280 stars 29 forks source link

Dynamically align columns on app column length #9

Closed fatso83 closed 1 year ago

fatso83 commented 1 year ago

This closes issue #5 by dynamically aligning the output to the longest app name, as 30 was not sufficient. Another minor fix is upping the max number of watches from 1K-1 (3 digits) to 1M-1 (6 digits), as it is very common to have many tens of thousands of watches in a normal frontend project (as seen in the output below). This should allow for the normal case, plus more extreme cases :)

Regard this as work-in-progress as I just made it work and will then wait on feedback for how to "do this the proper C++ way". For instance, I am not sure how I can dynamically set the column width and still retian argument checking for the printf function. I also suspect there are better ways of comparing size_t/size_type and unsigned int, getting the max value of a field in a list of objects, etc.

Before

image

After

image

mikesart commented 1 year ago

Hi @fatso83. I'm on a trip and can't build / test this. From looking over the changes I think a more optimal solution would be to use the .precision for printf. Description:

.* The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted.

I'll merge this in and we can update as needed though. Thanks much for the patch - appreciate it!

mikesart commented 1 year ago

I pushed a new revision of this... let me know how it works (or not). Thanks!