git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4] git remote: Separate usage strings for subcommands

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 20, 2009, 09:36 UTC
Message-ID
<7vskc95yhd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<32c343770911191058x7be7d34ascc3564064b880213@mail.gmail.com>
Tim Henigan <tim.henigan@gmail.com> writes:
Show 16 quoted lines
> Using the 'add' subcommand as an example, the desired output is:
>
> Output of 'git remote -h':
>     "git remote [-v | --verbose]"
>     "git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>"
>     etc.
>
> Output of 'git remote add -h':
>     "git remote add [<options>...] <name> <url>"
>     followed by the detailed description given by 'parse_options()'.
>
> Text in 'man git-remote':
>     "git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>"
>     with the options explained in detail later in the file.
>
> Thanks for your patience,
I think the above looks good; thank _you_ for your patience.

I often wonder if we want to add to the parse-options library a function that takes a "const struct option *" and some other unspecified hints, and fills a strbuf with a one-line description, e.g.

    "[-t <branch>] [-m <master>] [-f] [--mirror]"

I expect we would eventually want to handle something like (this example is from "git push"):

    "[--all | --mirror | --tags] [-n | --dry-run]"

and walking elements in a "struct option" one by one wouldn't give us enough information to group all/mirror/tags in "one of these" brackets, and that is what I mean by "some other unspecified hints". Obviously we could do the "[-n|--dry-run]" with existing information.

A helper function like that may make things a bit easier. parse_options() may need to take a custom callback function of some sort so that you can override what parse_options_usage() does when responding to "remote -h" and generate the list of subcommands and their options on the fly, though.

But that is all outside the scope of this particular patch.
Previous: Tim Henigan
Message 6 of 6 in “git remote: Separate usage strings for subcommands”
  1. git remote: Separate usage strings for subcommandsTim Henigan, Nov 19, 2009
  2. Nanako ShiraishiNov 19, 2009
  3. Tim HeniganNov 19, 2009
  4. Junio C HamanoNov 19, 2009
  5. Tim HeniganNov 19, 2009
  6. Junio C HamanoNov 20, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.