Skip to content

tool_listhelp: easier to generate with gen.pl - #7787

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/tool_listhelp
Closed

tool_listhelp: easier to generate with gen.pl#7787
bagder wants to merge 2 commits into
masterfrom
bagder/tool_listhelp

Conversation

@bagder

@bagder bagder commented Sep 28, 2021

Copy link
Copy Markdown
Member

tool_listhelp.c is now a separate file with only the command line --help
output, exactly as generated by gen.pl. This makes it easier to generate
updates according to what's in the docs/cmdline-opts docs.

cd $srcroot/docs/cmdline-opts
./gen.pl listhelp *.d > $srcroot/src/tool_listhelp.c

@gvanem

gvanem commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

Would it be possible to make gen.pl generate a frontpage help a bit nicer like this:

Usage: curl [options...] <url>
 -d, --data <data>          HTTP POST data
 -f, --fail                 Fail silently (no output at all) on HTTP errors
 -h, --help <category>      Get help for commands
 -i, --include              Include protocol response headers in the output
 -o, --output <file>        Write to file instead of stdout
 -O, --remote-name          Write output to a file named as the remote file
 -s, --silent               Silent mode
 -T, --upload-file <file>   Transfer local FILE to destination
 -u, --user <user:password> Server user and password
 -A, --user-agent <name>    Send User-Agent <name> to server
 -v, --verbose              Make the operation more talkative
 -V, --version              Show version number and quit

Since curl --help category is nice and aligned, so should this frontpage IMHO.

Or it could be done in tool_listhelp.c itself by something like:

static void print_category(curlhelp_t category)
{
  unsigned int i;
  size_t len, longest = 0;

  if (category & CURLHELP_IMPORTANT)
    for(i = 0; helptext[i].opt; ++i) {
       if(!(helptext[i].categories & CURLHELP_IMPORTANT))
         continue;
       len = strlen(helptext[i].opt);
       if (len > longest)
          longest = len;
    }
  else
     longest = 18;

  for(i = 0; helptext[i].opt; ++i)
    if(helptext[i].categories & category) {
      printf(" %-*s %s\n", longest, helptext[i].opt, helptext[i].desc);
    }
}

Edit: Maybe simply if (category == CURLHELP_IMPORTANT) if I understand this correctly.

@bagder
bagder force-pushed the bagder/tool_listhelp branch from cb6b7de to 8588a26 Compare September 29, 2021 10:34
@bagder

bagder commented Sep 29, 2021

Copy link
Copy Markdown
Member Author

We could even do it for all categories! And since that's not really related to this change, I'll do that in a separate PR.

@bagder

bagder commented Sep 29, 2021

Copy link
Copy Markdown
Member Author

See #7792 for how I took your proposal a little further.

@gvanem

gvanem commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

We could even do it for all categories!

Ok, fine. But maybe that could generate too much indent. Like in curl --help tls:

...
-E, --cert <certificate[:password]> Client certificate file and password
...
 --ssl                              Try SSL/TLS

@bagder

bagder commented Sep 29, 2021

Copy link
Copy Markdown
Member Author

Yes, which is why I attempted to only do it as wide as it can without wrapping...

bagder added a commit that referenced this pull request Sep 29, 2021
tool_listhelp.c is now a separate file with only the command line --help
output, exactly as generated by gen.pl. This makes it easier to generate
updates according to what's in the docs/cmdline-opts docs.

  cd $srcroot/docs/cmdline-opts
  ./gen.pl listhelp *.d > $srcroot/src/tool_listhelp.c

With a configure build, this also works:

  make -C src listhelp

Closes #7787
@bagder
bagder force-pushed the bagder/tool_listhelp branch from 8588a26 to e7dd7fa Compare September 29, 2021 12:21
@bagder

This comment has been minimized.

tool_listhelp.c is now a separate file with only the command line --help
output, exactly as generated by gen.pl. This makes it easier to generate
updates according to what's in the docs/cmdline-opts docs.

  cd $srcroot/docs/cmdline-opts
  ./gen.pl listhelp *.d > $srcroot/src/tool_listhelp.c

With a configure build, this also works:

  make -C src listhelp

Closes #7787
@bagder
bagder force-pushed the bagder/tool_listhelp branch from 1b6504a to 345f6bd Compare September 30, 2021 07:41
@bagder bagder closed this in ffb634d Sep 30, 2021
@bagder
bagder deleted the bagder/tool_listhelp branch September 30, 2021 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants