metal3d / bashsimplecurses

A simple curses library made in bash to draw terminal interfaces
BSD 3-Clause "New" or "Revised" License
921 stars 115 forks source link

Improving the Usage Output #64

Closed ghost closed 1 year ago

ghost commented 1 year ago

I feel that output needs some TLC. It's exhaustive for usage output. The formatting could do with a tidy. I would suggest looking into writing a man page, at this point, because there seems to be a lot of information to offer. What do you think?

I absolutely recommend a usage format like:

Usage: program [OPTS]

  -h, --help               - ...
  -v, --version            - ...
  ...                      - ...
  ...                      - ...

Some brief information here, if needed.

I might be biased, because I use it in all of my programs, but it's because it's so dang discreet and easy to read! Just as you'd expect from an overview of usage, where the man page ideally goes into more detail. I also ensure the line never exceeds <= 80 columns so that the information is readable; keeping things concise helps.

If you're curious and want to see some examples of what I have in mind, check out some of my projects in both Extra and PerlProjects, like Cito, GLKFU, AutoExec, LSBLK, CSi3, DTP, UbuChk, etc.

metal3d commented 1 year ago

You're right. I propose something in https://github.com/metal3d/bashsimplecurses/commit/0cd3f089eddb6836f6d0eeaab02bb4fda0fa6ea0

See the result here for "simple help":

bash simple_curses.sh -h
This file is a library not meant to be run. Source it in a main script.

Usage: simple_curses.sh [options]
  -c,  --crop       Title is spread over multiple lines if necessary
                    Using -c, the title will be cropped to fit in 
                    window width
  -h,  --help       Displays this help message
  -hh, --more-help  Displays extended help message with more documentation
  -t,  --time [t]   Sleep time, in seconds, when no "update" function has
                    been defined, this option is used when calling the 
                    "update" function
  -s,  --scroll     Set presentation to scrolling mode.
  -q,  --quiet      There will be no warning messages at all
  -V,  --verbose    Append debug messages after the layout

And the extended help:

bash simple_curses.sh -hh
This file is a library not meant to be run. Source it in a main script.

Usage: simple_curses.sh [options]
  -c,  --crop       Title is spread over multiple lines if necessary
                    Using -c, the title will be cropped to fit in 
                    window width
  -h,  --help       Displays this help message
  -hh, --more-help  Displays extended help message with more documentation
  -t,  --time [t]   Sleep time, in seconds, when no "update" function has
                    been defined, this option is used when calling the 
                    "update" function
  -s,  --scroll     Set presentation to scrolling mode.
  -q,  --quiet      There will be no warning messages at all
  -V,  --verbose    Append debug messages after the layout

Displays windows in a layout using commands. User defines a "main" function, 
then calls this script main loop. The current help presents the options of the 
main loop function, presentation mode and layout usage.

Presentation mode:
==================
  The screen is either managed as a static dashboard (default) or scrolling 
mode. The later enables seeing older displays by scrolling back in the terminal 
emulator window.
  In static mode, the window is cleared and the layout is reset to top left 
corner.
  In scrolling mode, the window is not cleared and the layout is just reset to 
the left border, leaving older display available for reading.
  Some window, like progress bar, loose their interest in scrolling mode, but 
are compatible.
  In scrolling mode, new layout starts under the previous one. There is no 
screen clearing. In default, dashboard mode, the cursor is placed at the top 
left corner.

Layout usage:
=============
  Start window creation using "window" function. Width can be direct and 
percent of the full display area. User can enter more than 100%, there is no 
consistency check, result in unpredictable.
  End window creation using "endwin" function
  Windows can only be placed next to each other using "col_right" and/or 
"move_up" functions. This leads to 4 possible placement:
  - window under the previous one : start new window directly after endwin
  - Window on the right of the previous one : use col_right
  - Window on the right starting from first line : use col_right then move_up
  - Start from the bottom of the current one, first row : use move_up
  See examples, especially wintest.sh to see all possible usages.
ghost commented 1 year ago

That's more like it! Many times better. Far more readable and presentable.

BTW:

Some window windows, like progress bar, loose lose their interest in scrolling mode, but

mode. The later latter enables seeing older displays by scrolling back in the terminal

By...

In default, dashboard mode, the cursor is placed at the top left corner.

Do you mean that by default, in the dashboard mode, the cursor is placed at the top-left corner? Or to phrase it another way: in the dashboard mode, the cursor is by default placed at the top-left corner? If so, it might be best to reword it, because I think it's a little confusing.

metal3d commented 1 year ago

Corrections done from your comments. Thanks a lot!