more compact pgetopts help #27

Closed
opened 2022-08-09 14:17:28 +02:00 by ni · 1 comment
ni commented 2022-08-09 14:17:28 +02:00 (Migrated from git.w21.org)

For simplicity, the output of ovc.ovc_help() has the options and their help text on different lines. That enables a horizontally compact output with minimal effort. But it isn't as verticall compact as it could be, and it leaves something to be desired aesthetically.

So, a nicer-looking albeit not as horizontally compact output is desired. It could look like this:

usage: psg [-Wio] [-f FIELD] [-F FIELD] [-p ARG,...] pattern ...
Find argument(s) (a regexp) in ps output

 -?, --help:              show help on options and things
 -F, --match-field FIELD: print where field == argument (str arg, default False)
 -W, --term-width:        limit output to terminal width
 -f, --in-field FIELD:    find argument in field (str arg, default False)
 -h, --help:              show help on options and things
 -i, --ignorecase:        ignore upper/lowercase in match
 -o, --show-own:          show own entries ($0 and ps)
 -p, --ps-args ARG,...:   arguments to ps command (str arg, default 'aux')

This is just a mockup, sadly. But it shows that even options with longish names and an argument and a default value can fit into 80 characters (which just does, just so). Drawback: a double loop, one to do the option strings, one to do the padding.

If this isn't sufficient, the user can insert "\n\t" (or more tabs) as appropriate to have a line break followed by some indentation in the optoin's explanation.

Rationale: In this case, I put simplicity of the implementation before user convenience in a rarer case.

For simplicity, the output of `ovc.ovc_help()` has the options and their help text on different lines. That enables a horizontally compact output with minimal effort. But it isn't as verticall compact as it could be, and it leaves something to be desired aesthetically. So, a nicer-looking albeit not as horizontally compact output is desired. It could look like this: usage: psg [-Wio] [-f FIELD] [-F FIELD] [-p ARG,...] pattern ... Find argument(s) (a regexp) in ps output ``` -?, --help: show help on options and things -F, --match-field FIELD: print where field == argument (str arg, default False) -W, --term-width: limit output to terminal width -f, --in-field FIELD: find argument in field (str arg, default False) -h, --help: show help on options and things -i, --ignorecase: ignore upper/lowercase in match -o, --show-own: show own entries ($0 and ps) -p, --ps-args ARG,...: arguments to ps command (str arg, default 'aux') ``` This is just a mockup, sadly. But it shows that even options with longish names and an argument _and_ a default value can fit into 80 characters (which just does, just so). Drawback: a double loop, one to do the option strings, one to do the padding. If this isn't sufficient, the user can insert "\n\t" (or more tabs) as appropriate to have a line break followed by some indentation in the optoin's explanation. Rationale: In this case, I put simplicity of the implementation before user convenience in a rarer case.
ni commented 2022-08-09 14:17:28 +02:00 (Migrated from git.w21.org)

assigned to @ni

assigned to @ni
ni (Migrated from git.w21.org) closed this issue 2022-08-12 16:18:14 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
w21/jpylib#27
No description provided.