Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool_listhelp: easier to generate with gen.pl #7787

Closed
wants to merge 2 commits into from
Closed

Conversation

@bagder
Copy link
Member

@bagder bagder commented Sep 28, 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

@gvanem
Copy link
Contributor

@gvanem gvanem commented Sep 29, 2021

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 Sep 29, 2021
@bagder
Copy link
Member Author

@bagder bagder commented Sep 29, 2021

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
Copy link
Member Author

@bagder bagder commented Sep 29, 2021

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

@gvanem
Copy link
Contributor

@gvanem gvanem commented Sep 29, 2021

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
Copy link
Member Author

@bagder bagder commented Sep 29, 2021

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

bagder added a commit that referenced this issue 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 Sep 29, 2021
@bagder

This comment has been hidden.

bagder added 2 commits Sep 30, 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 1b6504a to 345f6bd Sep 30, 2021
@bagder bagder closed this in ffb634d Sep 30, 2021
@bagder bagder deleted the bagder/tool_listhelp branch Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants