• Usage/Help Screen Conventions

    From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Thu Nov 6 04:29:45 2025
    From Newsgroup: comp.lang.c

    Rounding the corner to completion on a project
    I've worked on for 5 or 6 years & now I'm stumped
    by a very simple thing...

    When the user passes no arguments, I default to
    the panel below, yet I wonder if its expressed
    concisely enough to avoid confusion or promote it...

    I don't feel its too bad, but then again I know
    what its doing while others wont.

    Hoping to read responses on you'd express this.

    Syntax: tinybase OPTION - INPUT

    Options (use 1 option per invocation):

    Tag query: -q 'comma seperated queries'
    Tag index: -t
    Tinybase manual: -m

    Input:

    File list: - file1 file2 file3
    Stdin: - <<EOF

    Examples:

    tinybase -q 'query1, query2, query3' - *.txt
    tinybase -t - *.txt
    tinybase -m > manual.txt
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c on Thu Nov 6 06:40:43 2025
    From Newsgroup: comp.lang.c

    On 06.11.2025 05:29, Michael Sanders wrote:
    Rounding the corner to completion on a project
    I've worked on for 5 or 6 years & now I'm stumped
    by a very simple thing...

    When the user passes no arguments, I default to
    the panel below, yet I wonder if its expressed
    concisely enough to avoid confusion or promote it...

    I don't feel its too bad, but then again I know
    what its doing while others wont.

    Hoping to read responses on you'd express this.

    There's no clear standard and you can certainly find
    various forms. It's probably also depending on taste
    to some degree. But there's also a common subset that
    you often find. Some impressions on the sample below...


    Syntax: tinybase OPTION - INPUT

    I find a line like this not very useful (per se).


    Options (use 1 option per invocation):

    If that's the case you don't really need a '-' or '--'
    to terminate options.


    Tag query: -q 'comma seperated queries'
    Tag index: -t
    Tinybase manual: -m

    Input:

    File list: - file1 file2 file3
    Stdin: - <<EOF

    While file arguments are part of the interface syntax
    redirections (like <<EOF) are just technical shell
    building blocks; I wouldn't include them in the usage
    description.


    Examples:

    tinybase -q 'query1, query2, query3' - *.txt
    tinybase -t - *.txt
    tinybase -m > manual.txt

    Examples are fine (but '-' is syntactically unnecessary).
    A description is completely missing. (And a manual page
    should also have information about exit status codes.)

    My preference for usage information goes in the direction
    (despite being also - like your "Syntax" line - formally
    not perfectly accurate)...


    Synopsis:
    tinybase [ -q queries... | -t | -m ] files...

    Options:
    -q queries... comma separated list of queries
    -t <tag index?>
    -m show manual

    Description:
    ...

    Examples:
    tinybase -q 'query1, query2, query3' - *.txt
    tinybase -t - *.txt
    tinybase -m > manual.txt


    Where a quick usage help would just print a single line
    Usage: tinybase [ -q queries... | -t | -m ] files...
    and a verbose information or manual page would show the
    complete information. (I would support both, terse usage
    and full information. No arguments provided could just
    show the usage and '-?' or similar could provide details.
    There's various possibilities depending on the character
    and complexity of the tool, what information you want to
    obtain quickly and when you need details.)

    I also suggest to just inspect what other programs and
    tools do here. You will get a feeling then what's there
    and whether it's enough for you to understand that tool.
    Add thereby identifying those sections and contents in
    your info page that is missing in your tool-information
    to understand it.

    Janis

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Heathfield@rjh@cpax.org.uk to comp.lang.c on Thu Nov 6 06:24:35 2025
    From Newsgroup: comp.lang.c

    On 06/11/2025 04:29, Michael Sanders wrote:
    Rounding the corner to completion on a project
    I've worked on for 5 or 6 years & now I'm stumped
    by a very simple thing...

    When the user passes no arguments, I default to
    the panel below, yet I wonder if its expressed
    concisely enough to avoid confusion or promote it...

    I don't feel its too bad, but then again I know
    what its doing while others wont.

    Don't try and teach in an if(argc <

    People who type the program name alone need one of two things:

    a) a brief description of the program's purpose;

    OR

    b) a brief reminder of usage.

    Here's an example from my own corpus:

    $ transpose
    transpose infile amount [outfile]
    transposes a Lilypond metafile ($TRANSPOSE$ tag present)
    from one key to another.
    infile: the file to transpose
    amount: number of semitones to transpose (-ve = down, +ve = up)
    outfile: if specified, output is written here.
    Otherwise, the input file is modified.


    That's enough to
    a) tell you whether it's the program you wanted, or
    b) remind you of how you use it

    It doesn't try to teach you music theory. If your program needs a
    manual, your descriptive passage should point at it - eg See
    README for more details.

    Syntax: tinybase OPTION - INPUT

    I'd say FILE(S) rather than INPUT

    Options (use 1 option per invocation):

    OPTION: one of

    Tag query: -q 'comma seperated queries'

    sepArated - but it's not clear whether the 'text in quotes' is
    part of the syntax or just an aside.

    Input:

    FILE(S) is less ambiguous. If your user doesn't know what files
    are and you try to teach him, you're in for a world of hurt.
    --
    Richard Heathfield
    Email: rjh at cpax dot org dot uk
    "Usenet is a strange place" - dmr 29 July 1999
    Sig line 4 vacant - apply within
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Fri Nov 7 10:43:33 2025
    From Newsgroup: comp.lang.c

    On Thu, 6 Nov 2025 06:40:43 +0100, Janis Papanagnou wrote:

    While file arguments are part of the interface syntax
    redirections (like <<EOF) are just technical shell
    building blocks; I wouldn't include them in the usage
    description.

    Noted.

    Examples are fine (but '-' is syntactically unnecessary).
    A description is completely missing. (And a manual page
    should also have information about exit status codes.)

    Yes.

    My preference for usage information goes in the direction
    (despite being also - like your "Syntax" line - formally
    not perfectly accurate)...


    Synopsis:
    tinybase [ -q queries... | -t | -m ] files...

    Options:
    -q queries... comma separated list of queries
    -t <tag index?>
    -m show manual

    Description:
    ...

    Examples:
    tinybase -q 'query1, query2, query3' - *.txt
    tinybase -t - *.txt
    tinybase -m > manual.txt

    That's closer to what I what in fact.

    As always, thanks Janis, lots of good info.
    Slowly but surely I move forward.
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Fri Nov 7 10:47:32 2025
    From Newsgroup: comp.lang.c

    On Thu, 6 Nov 2025 06:24:35 +0000, Richard Heathfield wrote:

    Don't try and teach in an if(argc <

    People who type the program name alone need one of two things:

    a) a brief description of the program's purpose;

    OR

    b) a brief reminder of usage.

    That's it right there.

    Here's an example from my own corpus:

    $ transpose
    transpose infile amount [outfile]
    transposes a Lilypond metafile ($TRANSPOSE$ tag present)
    from one key to another.
    infile: the file to transpose
    amount: number of semitones to transpose (-ve = down, +ve = up)
    outfile: if specified, output is written here.
    Otherwise, the input file is modified.

    That's enough to
    a) tell you whether it's the program you wanted, or
    b) remind you of how you use it

    It doesn't try to teach you music theory. If your program needs a
    manual, your descriptive passage should point at it - eg See
    README for more details.

    Yes, understood.

    FILE(S) is less ambiguous. If your user doesn't know what files
    are and you try to teach him, you're in for a world of hurt.

    Solid reply Richard, many thanks for the insights.

    Glad I asked now. Between you & Janis I've got (knock on wood)
    most of what I need now.
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Ben Bacarisse@ben@bsb.me.uk to comp.lang.c on Fri Nov 7 13:08:26 2025
    From Newsgroup: comp.lang.c

    Michael Sanders <porkchop@invalid.foo> writes:

    When the user passes no arguments, I default to
    the panel below, yet I wonder if its expressed
    concisely enough to avoid confusion or promote it...

    You've had good answers, but I'll add a couple of remarks that I don't
    think came up.

    Syntax: tinybase OPTION - INPUT

    Avoid - as a separator in either descriptions or argument lists as it is
    used so often for flags. I can't tell is I need to type it or if you
    are using it simply as a textual description device.

    Options (use 1 option per invocation):

    Tag query: -q 'comma seperated queries'
    Tag index: -t
    Tinybase manual: -m

    These options are, essentially, "modes". The utility provides three
    things it can do and they can't be mixed. Some utilities use alternate
    names: tinybase-query, tinybase-tag and tinybase-manual would all be
    symbolic links to one executable. That's probably over the top for this program, but I would describe it as three separate use cases with three separate syntax lines.

    Input:

    File list: - file1 file2 file3
    Stdin: - <<EOF

    You don't need to tell people about << (or > below). For one thing, you
    can't cover all the bases (what about <(...) or <<<word or <<'EOF' vs
    <<EOF?) and for another, your uses will know these basics.

    Examples:

    tinybase -q 'query1, query2, query3' - *.txt
    tinybase -t - *.txt
    tinybase -m > manual.txt

    Your examples show me that the - is needed as a required separator
    (except for -m). That's not very "unixy". I would prefer the file
    names to be assumed and the queries explicit as that is more in line
    with what old timers might expect:

    tinybase -q query1 -q query2 -q query3 *.txt
    tinybase -t *.txt
    tinybase -m

    I.e. the three syntax lines might be

    tinybase -m
    tinybase -t [file names...]
    tinybase -q query [-q query]... [file names...]
    --
    Ben.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Fri Nov 7 19:25:35 2025
    From Newsgroup: comp.lang.c

    On Fri, 07 Nov 2025 13:08:26 +0000, Ben Bacarisse wrote:

    These options are, essentially, "modes". The utility provides three
    things it can do and they can't be mixed. Some utilities use alternate names: tinybase-query, tinybase-tag and tinybase-manual would all be
    symbolic links to one executable. That's probably over the top for this program, but I would describe it as three separate use cases with three separate syntax lines.

    Well hey there Ben, hope you're doing alright.

    Also hope Janis & Richard are reading too as I've tried
    to incorporate the best of all three of your replies.

    Here's where I'm at (like your 'mode' anaology):

    Usage: tinybase [ -q queries... | -t | -m ] [ files... ]

    Options:

    -q query mode: find blocks with matching tags or wildcards
    example: tinybase -q 'query1, query2' files
    (if no files are given, reads from standard input)

    -t tag index mode: list all unique tags across the given files
    example: tinybase -t files

    -m manual mode: show the built-in documentation

    Notes:

    Multiple queries are comma-separated.
    Wildcards (*, ?) are supported in queries.
    When no files are provided, stdin is read automatically.
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c on Fri Nov 7 19:43:28 2025
    From Newsgroup: comp.lang.c

    On Fri, 7 Nov 2025 19:25:35 -0000 (UTC), Michael Sanders wrote:

    Here's where I'm at (like your 'mode' anaology):

    Usage: tinybase [ -q queries... | -t | -m ] [ files... ]

    Options:

    -q query mode: find blocks with matching tags or wildcards
    example: tinybase -q 'query1, query2' files (if no files are
    given, reads from standard input)

    -t tag index mode: list all unique tags across the given files
    example: tinybase -t files

    -m manual mode: show the built-in documentation

    Notes:

    Multiple queries are comma-separated.
    Wildcards (*, ?) are supported in queries.
    When no files are provided, stdin is read automatically.

    Now you’re starting to write an entire man page within your program.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c on Fri Nov 7 19:51:28 2025
    From Newsgroup: comp.lang.c

    Michael Sanders <porkchop@invalid.foo> writes:
    On Fri, 07 Nov 2025 13:08:26 +0000, Ben Bacarisse wrote:

    These options are, essentially, "modes". The utility provides three
    things it can do and they can't be mixed. Some utilities use alternate
    names: tinybase-query, tinybase-tag and tinybase-manual would all be
    symbolic links to one executable. That's probably over the top for this
    program, but I would describe it as three separate use cases with three
    separate syntax lines.

    Well hey there Ben, hope you're doing alright.

    Also hope Janis & Richard are reading too as I've tried
    to incorporate the best of all three of your replies.

    Here's where I'm at (like your 'mode' anaology):

    Usage: tinybase [ -q queries... | -t | -m ] [ files... ]

    Options:

    -q query mode: find blocks with matching tags or wildcards
    example: tinybase -q 'query1, query2' files
    (if no files are given, reads from standard input)

    It is common for utilities to accept '-' as a filename
    which indicates that input should come from stdin.

    For example;

    NAME
    cat - concatenate files and print on the standard output

    SYNOPSIS
    cat [OPTION]... [FILE]...

    DESCRIPTION
    Concatenate FILE(s) to standard output.

    With no FILE, or when FILE is -, read standard input.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Fri Nov 7 19:51:29 2025
    From Newsgroup: comp.lang.c

    On Fri, 7 Nov 2025 19:43:28 -0000 (UTC), Lawrence D’Oliveiro wrote:

    Now you’re starting to write an entire man page within your program.

    Emacs! =)

    I'm working on whittling it down Lawrence, its just that I cant hit
    that elusive (for me) mark between terse/concise.
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Fri Nov 7 19:57:27 2025
    From Newsgroup: comp.lang.c

    On Fri, 07 Nov 2025 19:51:28 GMT, Scott Lurndal wrote:

    It is common for utilities to accept '-' as a filename
    which indicates that input should come from stdin.

    For example;

    NAME
    cat - concatenate files and print on the standard output

    Hi Scott & thanks for the input.

    I'm studying cat, grep, etc... & my sed...

    is close to ambiguous (from a newbie's point of view):

    Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Heathfield@rjh@cpax.org.uk to comp.lang.c on Fri Nov 7 21:25:52 2025
    From Newsgroup: comp.lang.c

    On 07/11/2025 19:25, Michael Sanders wrote:
    On Fri, 07 Nov 2025 13:08:26 +0000, Ben Bacarisse wrote:

    These options are, essentially, "modes". The utility provides three
    things it can do and they can't be mixed. Some utilities use alternate
    names: tinybase-query, tinybase-tag and tinybase-manual would all be
    symbolic links to one executable. That's probably over the top for this
    program, but I would describe it as three separate use cases with three
    separate syntax lines.

    Well hey there Ben, hope you're doing alright.

    Also hope Janis & Richard are reading too as I've tried
    to incorporate the best of all three of your replies.

    Here's where I'm at (like your 'mode' anaology):

    Usage: tinybase [ -q queries... | -t | -m ] [ files... ]

    Options:

    -q query mode: find blocks with matching tags or wildcards
    example: tinybase -q 'query1, query2' files
    (if no files are given, reads from standard input)

    -t tag index mode: list all unique tags across the given files
    example: tinybase -t files

    -m manual mode: show the built-in documentation

    Notes:

    Multiple queries are comma-separated.
    Wildcards (*, ?) are supported in queries.
    When no files are provided, stdin is read automatically.

    I'm pretty sure I've read every article in this thread, but I
    still have no idea what tinybase actually does. Is it an analyser
    for alkaline chemical structures, or a nucleobase designer, or a
    microRDBMS, or what?

    tinybase really ought to tell you that, in just a sentence or two.
    --
    Richard Heathfield
    Email: rjh at cpax dot org dot uk
    "Usenet is a strange place" - dmr 29 July 1999
    Sig line 4 vacant - apply within
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Fri Nov 7 22:50:49 2025
    From Newsgroup: comp.lang.c

    On Fri, 7 Nov 2025 21:25:52 +0000, Richard Heathfield wrote:

    I'm pretty sure I've read every article in this thread, but I
    still have no idea what tinybase actually does. Is it an analyser
    for alkaline chemical structures, or a nucleobase designer, or a
    microRDBMS, or what?

    tinybase really ought to tell you that, in just a sentence or two.

    Yup you're absolutely right. Here's my latest. Getting close...

    Usage: tinybase [ -q queries... | -t | -r | -m ] [ files... ]

    Synopsis: Tag based search tool

    Options:

    -q query mode: find blocks with matching tags or wildcards
    example: tinybase -q 'query1, query2' files

    -t tag index mode: list all unique tags across given files
    example: tinybase -t files

    -r repl mode: interactive shell for tag queries
    example: tinybase -r files

    -m manual mode: show built-in documentation
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c on Fri Nov 7 15:24:25 2025
    From Newsgroup: comp.lang.c

    Michael Sanders <porkchop@invalid.foo> writes:
    On Fri, 7 Nov 2025 21:25:52 +0000, Richard Heathfield wrote:
    I'm pretty sure I've read every article in this thread, but I
    still have no idea what tinybase actually does. Is it an analyser
    for alkaline chemical structures, or a nucleobase designer, or a
    microRDBMS, or what?

    tinybase really ought to tell you that, in just a sentence or two.

    Yup you're absolutely right. Here's my latest. Getting close...

    Usage: tinybase [ -q queries... | -t | -r | -m ] [ files... ]

    Synopsis: Tag based search tool

    Options:

    -q query mode: find blocks with matching tags or wildcards
    example: tinybase -q 'query1, query2' files

    -t tag index mode: list all unique tags across given files
    example: tinybase -t files

    -r repl mode: interactive shell for tag queries
    example: tinybase -r files

    -m manual mode: show built-in documentation

    I would remove most or all of the blank lines, just to avoid using up
    too much of the user's screen real estate. The longer your usage
    message, the more of the user's on-screen information might be lost.

    For a program that requires at least some command-line arguments, a very
    short message that points the user to a "-h" or "--help" option can be
    useful. Don't show a very long usage message unless the user explicitly
    asks for it. GNU coreutils rm is a decent example:

    $ rm
    rm: missing operand
    Try 'rm --help' for more information.

    "rm --help" prints a 39-line message. (I'm not going to get into
    whether "-h" or "--help" is better. The latter is a GNU convention.)

    Unfortunately, this doesn't work for a command that can validly be run
    with no arguments, like cat.

    Print error messages to stderr, usage messages (at least if
    requested via some kind of help option) to stdout. I've seem
    commands where "foo --help" prints more text than can fit on my
    screen, and "foo --help | less" shows me nothing because the output
    I asked for was sent to stderr. (This is getting a bit OS-specific,
    but it's applicable to any Unix-like system, and your use of '-'
    to introduce arguments suggest that that's what you're aiming for.)

    Something else you might consider is how you handle the different
    modes. If I understand correctly (and I'm not at all sure I do),
    "-q", "-t", "-r", and "-m" are distinct modes, and you have
    to specify exactly one. If that's the case, you might consider
    making them subcommands, similar to the way "git" has "git commit",
    "git log", et al.

    tinybase query ...
    tinybase tag ...
    tinybase repl ...
    tinybase manual ...

    If you like, you can allow the subcommand name to be abbreviated.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c on Sat Nov 8 02:49:24 2025
    From Newsgroup: comp.lang.c

    On 08.11.2025 00:24, Keith Thompson wrote:
    [...]

    For a program that requires at least some command-line arguments, a very short message that points the user to a "-h" or "--help" option can be useful. Don't show a very long usage message unless the user explicitly
    asks for it. [...]

    The previously already mentioned two-level help is indeed to prefer.


    "rm --help" prints a 39-line message. (I'm not going to get into
    whether "-h" or "--help" is better. The latter is a GNU convention.)

    The problem with a choice of -h for that is that this letter h might
    be a good choice for an existing functional option and would then not
    be available any more for that. (I thus consider this "convention" a
    badly decided thing as far as -h is concerned, while --help is okay.)

    We've thus used -? for that usage purpose, a _non-letter_ character;
    it was standard in all our tools and I'm still using that convention
    in my private context.

    In that light it's also interesting to have a look into ksh's getopts
    built-in function. If you use that function in your programs you have automatically some help standard formats and outputs generated. If
    you type (in ksh) getopts --man you will get its man-page and find at
    the bottom these built-ins standards for help information:
    -? To generate a usage synopsis.
    --?? To generate a verbose usage message.
    --??man
    To generate a formatted man page.
    --??api
    To generate an easy to parse usage message.
    --??html
    To generate a man page in html format.
    --??nroff
    To generate a man page in nroff format.
    --??usage
    List the current optstring.

    That comes all for free [when using ksh getopts].

    But the choices are IMO also a good paragon; -? for single line usage,
    --?? for a verbose information. (For the latter I'd prefer --help and
    instead of --??man it seems that --man also suffices; that at least
    produces the same result for getopts --man and getopts --??man.)

    For a three-level verbosity, -?, --help, --man, would be my choice.


    Unfortunately, this doesn't work for a command that can validly be run
    with no arguments, like cat.

    Programs that accept no arguments (e.g. in filters that assume input
    from stdin instead of from files then) you would have to use something
    like -? (although cat, specifically, doesn't support that, sadly). For
    other programs, those that need arguments, omitting any argument should
    produce a one-liner usage message, IMO. Using -? could be widely used
    for all cases.


    Print error messages to stderr, usage messages (at least if
    requested via some kind of help option) to stdout. I've seem
    commands where "foo --help" prints more text than can fit on my
    screen, and "foo --help | less" shows me nothing because the output
    I asked for was sent to stderr.

    This is also what ksh does. I think that's a very unfortunate decision; especially because of the reason you mentioned, piping through a pager.

    Janis

    [...]


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.lang.c on Fri Nov 7 19:00:13 2025
    From Newsgroup: comp.lang.c

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    The problem with a choice of -h for that is that this letter h might
    be a good choice for an existing functional option and would then not
    be available any more for that. (I thus consider this "convention" a
    badly decided thing as far as -h is concerned, while --help is okay.)

    We've thus used -? for that usage purpose, a _non-letter_ character;
    it was standard in all our tools and I'm still using that convention
    in my private context.
    [...]

    '?' is a shell wildcard, matching a single character in a file name.

    "foo -?" will expand to "foo -x" if you happen to have a file in
    the current directory named "-x" (and foo's "-x" option obviously
    tells it to delete your home directory). If you have no such file,
    the behavior of "foo -?" depends on your shell and its settings,
    but typically no substitution takes place.

    This is specific to the behavior of shells on Unix-like systems,
    but if you're writing a C program intended to work on such systems
    (and possibly others), it's good to be aware of the issue.

    Few Unix commands use "-?" to mean "print a usage message".
    For those that do, I would escape the question mark.
    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Heathfield@rjh@cpax.org.uk to comp.lang.c on Sat Nov 8 04:38:53 2025
    From Newsgroup: comp.lang.c

    On 07/11/2025 23:24, Keith Thompson wrote:

    <snip>

    "rm --help" prints a 39-line message.

    Of which the top two are:

    Usage: rm [OPTION]... [FILE]...
    Remove (unlink) the FILE(s).

    I know what a file is, but what the hell is a tag? Graffiti tag?
    Dog tag? Ear tag? Electronic tag? Kimball tag? Pet tag? Price
    tag? RFID tag? Toe tag? Triage tag?

    Don't be an idiot, Richard! It'll be computer-related, *obviously*.

    Oh, of course... except that, under 'Computing', Wikipedia's
    disambiguation page for 'tag' lists a dozen entries.

    So I *still* don't know what tinybase does. It's like you're
    trying to hide it.
    --
    Richard Heathfield
    Email: rjh at cpax dot org dot uk
    "Usenet is a strange place" - dmr 29 July 1999
    Sig line 4 vacant - apply within
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.c on Sat Nov 8 07:58:31 2025
    From Newsgroup: comp.lang.c

    On Fri, 7 Nov 2025 19:51:29 -0000 (UTC), Michael Sanders wrote:

    On Fri, 7 Nov 2025 19:43:28 -0000 (UTC), Lawrence D’Oliveiro wrote:

    Now you’re starting to write an entire man page within your program.

    Emacs! =)

    I'm working on whittling it down Lawrence, its just that I cant hit that elusive (for me) mark between terse/concise.

    These days, I don’t bother. For more complex projects, I write up a
    detailed man page and include it with the program.

    Probably my largest such project: <https://gitlab.com/ldo/render-useful/>
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.c on Sat Nov 8 11:09:51 2025
    From Newsgroup: comp.lang.c

    On 08.11.2025 04:00, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    The problem with a choice of -h for that is that this letter h might
    be a good choice for an existing functional option and would then not
    be available any more for that. (I thus consider this "convention" a
    badly decided thing as far as -h is concerned, while --help is okay.)

    We've thus used -? for that usage purpose, a _non-letter_ character;
    it was standard in all our tools and I'm still using that convention
    in my private context.
    [...]

    '?' is a shell wildcard, matching a single character in a file name.

    Yes, any files named like <dash><letter> will get then expanded
    in standard Unix shell (with standard settings), and one should
    be aware of that. It's good to mention that (since I forgot to
    do so)!

    In decades of practice I've not met such filenames in practice,
    though; and that's explainable, because it's semantically an
    arguably sensible name, and if you have files with such names
    you usually cannot use most of the Unix tools anyway (without
    precautions) since such filenames would be interpreted in tools
    as option so that most tools won't work with them; then you'd
    have to also indicate end-of-options with the tool (like '--')
    or use tool-specific "escape-options" (like in grep with '-e').

    But there sometimes also erroneously created files with such
    names in the file system, and (as you subsequently demonstrate
    it) such an inadvertently created file may make troubles then.


    "foo -?" will expand to "foo -x" if you happen to have a file in
    the current directory named "-x" (and foo's "-x" option obviously
    tells it to delete your home directory). If you have no such file,
    the behavior of "foo -?" depends on your shell and its settings,
    but typically no substitution takes place.

    (Or in shell context, where appropriate, you can also just
    disable the filename globbing so that it doesn't expand.)


    This is specific to the behavior of shells on Unix-like systems,
    but if you're writing a C program intended to work on such systems
    (and possibly others), it's good to be aware of the issue.

    Few Unix commands use "-?" to mean "print a usage message".
    For those that do, I would escape the question mark.

    In practice it doesn't seem to be necessary (mileages may
    vary), but quoting "locally" disables expansions and makes
    it safer for contexts where such filenames are used, indeed.

    Though, the additional characters (-\? or "-?" or '-?') may
    be considered an annoyance and a suboptimal choice of -? in
    the first place for contexts with dash-char named files.

    Janis

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Sat Nov 8 13:12:30 2025
    From Newsgroup: comp.lang.c

    On Fri, 07 Nov 2025 15:24:25 -0800, Keith Thompson wrote:

    I would remove most or all of the blank lines, just to avoid using up
    too much of the user's screen real estate. The longer your usage
    message, the more of the user's on-screen information might be lost.

    For a program that requires at least some command-line arguments, a very short message that points the user to a "-h" or "--help" option can be useful. Don't show a very long usage message unless the user explicitly
    asks for it. GNU coreutils rm is a decent example:

    $ rm
    rm: missing operand
    Try 'rm --help' for more information.

    "rm --help" prints a 39-line message. (I'm not going to get into
    whether "-h" or "--help" is better. The latter is a GNU convention.)

    Unfortunately, this doesn't work for a command that can validly be run
    with no arguments, like cat.

    Print error messages to stderr, usage messages (at least if
    requested via some kind of help option) to stdout. I've seem
    commands where "foo --help" prints more text than can fit on my
    screen, and "foo --help | less" shows me nothing because the output
    I asked for was sent to stderr. (This is getting a bit OS-specific,
    but it's applicable to any Unix-like system, and your use of '-'
    to introduce arguments suggest that that's what you're aiming for.)

    Something else you might consider is how you handle the different
    modes. If I understand correctly (and I'm not at all sure I do),
    "-q", "-t", "-r", and "-m" are distinct modes, and you have
    to specify exactly one. If that's the case, you might consider
    making them subcommands, similar to the way "git" has "git commit",
    "git log", et al.

    tinybase query ...
    tinybase tag ...
    tinybase repl ...
    tinybase manual ...

    If you like, you can allow the subcommand name to be abbreviated.

    Excellent info here Keith, many thanks. I have some thoughts on
    these things (bias is coming from a Windows world on this end)
    & I want to study your remarks more before I ask any questions,
    please stay tuned...
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Sat Nov 8 13:16:43 2025
    From Newsgroup: comp.lang.c

    On Sat, 8 Nov 2025 04:38:53 +0000, Richard Heathfield wrote:

    So I *still* don't know what tinybase does. It's like you're
    trying to hide it.

    No, not hiding anything, just moving slowly, learning as I go,
    trying to do the right thing. At any rate...

    Bearing in mind I'm defining my own terminology, tinybase
    (which is really only a working title & could change)
    searches for tagged blocks. Tagged blocks take this form:

    tags: 1998, analytics, sales, frank j. smith

    line 1
    line 2
    line nth...

    So if one invoked tinybase as...

    tinybase -q 'shuf*' *.tbf

    Here, the result is...

    FILE: data/awk.tbf
    LINE: 94
    BLOCK: 6
    QUERY: shuf*
    MATCH: shuffle

    TAGS: shuffle, awk, code, [numlines]

    001 # Fisher/Yates shuffle
    002
    003 function shuffle(card_array, number_of_cards, x, y, tmpvar) {
    004
    005 srand()
    006
    007 for (y = number_of_cards; y > 1; y--) {
    008 x = int((y-1) * rand()) + 1
    009 tmpvar = card_array[x]
    010 card_array[x] = card_array[y]
    011 card_array[y] = tmpvar
    012 }
    013
    014 }
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Heathfield@rjh@cpax.org.uk to comp.lang.c on Sat Nov 8 13:46:43 2025
    From Newsgroup: comp.lang.c

    On 08/11/2025 13:16, Michael Sanders wrote:

    <snip>

    trying to do the right thing.

    Fair enough. Here the right thing is to describe in a few words
    what your program does. Over a hundred isn't a few.

    I'd give you a hand, but after reading your 114-word description
    I was left none the wiser.

    I don't be think I'll be replying again because I'm not sure I
    can think of another way of saying 'describe in a few words what
    your program does'.
    --
    Richard Heathfield
    Email: rjh at cpax dot org dot uk
    "Usenet is a strange place" - dmr 29 July 1999
    Sig line 4 vacant - apply within
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Sat Nov 8 14:23:03 2025
    From Newsgroup: comp.lang.c

    On Sat, 8 Nov 2025 13:46:43 +0000, Richard Heathfield wrote:

    Fair enough. Here the right thing is to describe in a few words
    what your program does. Over a hundred isn't a few.

    I'd give you a hand, but after reading your 114-word description
    I was left none the wiser.

    I don't be think I'll be replying again because I'm not sure I
    can think of another way of saying 'describe in a few words what
    your program does'.

    Sorry I disagree: You're simultaneously telling me too much info
    is bad while too little is bad as well?
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c on Sat Nov 8 10:30:22 2025
    From Newsgroup: comp.lang.c

    On 2025-11-08 09:23, Michael Sanders wrote:
    On Sat, 8 Nov 2025 13:46:43 +0000, Richard Heathfield wrote:

    Fair enough. Here the right thing is to describe in a few words what
    your program does. Over a hundred isn't a few.

    I'd give you a hand, but after reading your 114-word description I
    was left none the wiser.

    I don't be think I'll be replying again because I'm not sure I can
    think of another way of saying 'describe in a few words what your
    program does'.

    Sorry I disagree: You're simultaneously telling me too much info
    is bad while too little is bad as well?

    No, the key thing he's pointing out it that it's not clear what the
    description you've provided means. At least, like Richard, after reading
    your description I had no idea what it was supposed to mean.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Sat Nov 8 15:50:31 2025
    From Newsgroup: comp.lang.c

    On Sat, 8 Nov 2025 10:30:22 -0500, James Kuyper wrote:

    No, the key thing he's pointing out it that it's not clear what the description you've provided means. At least, like Richard, after reading
    your description I had no idea what it was supposed to mean.

    Sure enough, I understand =) & Richard should hang in this thread,
    he's offered good ideas - a simple, clear description is needed.

    Bottom line: There's no way anyone can know what this app
    does in advance of twisting its knobs (even the description
    he offered for his own app presumes knowledge of 3rd party
    stuff after all).

    There's more work that needs to be done & speaking only for myself,
    its hardly ever going to be the case that less info presents
    a higher resolution picture & yet I press forward still.

    Thanks for your reply James I appreciate you trying to disambiguate.
    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael Sanders@porkchop@invalid.foo to comp.lang.c on Sat Nov 8 22:00:00 2025
    From Newsgroup: comp.lang.c

    On Sat, 8 Nov 2025 13:46:43 +0000, Richard Heathfield wrote:

    I don't be think I'll be replying again because I'm not sure I
    can think of another way of saying 'describe in a few words what
    your program does'.

    C'mon now Richard, its all good & lets keep it going. I'm just
    getting things together in the repl. yes lots still to do with
    descriptions but I'm getting closer see screen below. And this
    help panel still needs to be tweaked too...

    Enough out of me, still have to reply to Keith, hopefully as soon
    as Sunday evening.

    Use dot commands to control REPL or input query to scan tags

    Dot commands:

    .q Quit tinybase
    .h Display this help
    .c Clear screen
    .t Tag analytics
    .b Browse stack
    .m Display manual


    --
    :wq
    Mike Sanders
    --- Synchronet 3.21a-Linux NewsLink 1.2