Skip to content

Commit

Permalink
Generating options for man
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricereix committed Nov 2, 2023
1 parent 9e607d2 commit 64ce8c6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 23 deletions.
47 changes: 47 additions & 0 deletions bin/spec/cmdline-opts/generate_man.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
import sys
from option import Option

"""
Generate options for man
"""
from typing import *
import sys


def generate_man(options: List[Option]):
s = ""
for option in options:
if not option.deprecated:
s += generate_man_option(option)
s += "\n\n"
return s


def generate_man_option(option: Option):
s = "###"
if option.short:
s += " -%s," % option.short
s += " --%s" % option.long
if option.value:
s += " <%s>" % option.value
s += " {#%s}" % option.long.replace(".", "")
s += "\n\n"
s += option.description
return s


def main():
# Parse all options file given at the command line
if len(sys.argv) < 2:
print("usage: generate_nab.py OPTION_FILE1 OPTION_FILE2 ...")
sys.exit(1)
options = sorted(
[Option.parse_file(filename) for filename in sys.argv[1:]],
key=lambda option: option.long,
)
print(generate_man(options))


if __name__ == "__main__":
main()
46 changes: 23 additions & 23 deletions docs/manual/hurl.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ See also [`--key`](#key).

### --color {#color}

Colorize debug output (the HTTP response output is not colorized).
Colorize debug output (the HTTP response output is not colorized).

### --compressed {#compressed}

Expand Down Expand Up @@ -208,26 +208,20 @@ Combined with [`-b, --cookie`](#cookie), you can simulate a cookie storage betwe

Sets delay before each request.


### --error-format <FORMAT> {#error-format}

Control the format of error message (short by default or long)


### --file-root <DIR> {#file-root}

Set root file system to import files in Hurl. This is used for both files in multipart form data and request body.
When this is not explicitly defined, the files are relative to the current directory in which Hurl is running.

### -L, --location {#location}

Follow redirect. To limit the amount of redirects to follow use the [`--max-redirs`](#max-redirs) option

### --glob <GLOB> {#glob}

Specify input files that match the given glob pattern.

Multiple glob flags may be used. This flag supports common Unix glob patterns like *, ? and [].
Multiple glob flags may be used. This flag supports common Unix glob patterns like *, ? and [].
However, to avoid your shell accidentally expanding glob patterns before Hurl handles them, you must use single quotes or double quotes around each pattern.

### -0, --http1.0 {#http10}
Expand All @@ -248,21 +242,22 @@ For HTTP, this means Hurl attempts to upgrade the request to HTTP/2 using the Up

Tells Hurl to try HTTP/3 to the host in the URL, but fallback to earlier HTTP versions if the HTTP/3 connection establishment fails. HTTP/3 is only available for HTTPS and not for HTTP URLs.

### -i, --include {#include}

Include the HTTP headers in the output (last entry).

### --ignore-asserts {#ignore-asserts}

Ignore all asserts defined in the Hurl file.

### -i, --include {#include}

Include the HTTP headers in the output

### -k, --insecure {#insecure}

This option explicitly allows Hurl to perform "insecure" SSL connections and transfers.

### --interactive {#interactive}

Stop between requests.

This is similar to a break point, You can then continue (Press C) or quit (Press Q).

### -4, --ipv4 {#ipv4}
Expand All @@ -275,15 +270,20 @@ This option tells Hurl to use IPv6 addresses only when resolving host names, and

### --json {#json}

Output each hurl file result to JSON. The format is very closed to HAR format.
Output each hurl file result to JSON. The format is very closed to HAR format.

### --key <KEY> {#key}

Private key file name.

### -L, --location {#location}

Follow redirect. To limit the amount of redirects to follow use the [`--max-redirs`](#max-redirs) option

### --max-redirs <NUM> {#max-redirs}

Set maximum number of redirection-followings allowed

By default, the limit is set to 50 redirections. Set this option to -1 to make it unlimited.

### -m, --max-time <SECONDS> {#max-time}
Expand All @@ -303,6 +303,7 @@ Suppress output. By default, Hurl outputs the body of the last response.
### --noproxy <HOST(S)> {#noproxy}

Comma-separated list of hosts which do not use a proxy.

Override value from Environment variable no_proxy.

### -o, --output <FILE> {#output}
Expand All @@ -317,29 +318,29 @@ Tell Hurl to not handle sequences of /../ or /./ in the given URL path. Normally

Use the specified proxy.

### --report-junit <FILE> {#report-junit}

Generate JUnit File.

If the FILE report already exists, it will be updated with the new test results.

### --report-html <DIR> {#report-html}

Generate HTML report in DIR.

If the HTML report already exists, it will be updated with the new test results.

### --report-junit <FILE> {#report-junit}

Generate JUnit File.

If the FILE report already exists, it will be updated with the new test results.

### --report-tap <FILE> {#report-tap}

Generate TAP report.

If the FILE report already exists, it will be updated with the new test results.

### --resolve <HOST:PORT:ADDR> {#resolve} <HOST:PORT:ADDR>
### --resolve <HOST:PORT:ADDR> {#resolve}

Provide a custom address for a specific host and port pair. Using this, you can make the Hurl requests(s) use a specified address and prevent the otherwise normally resolved address to be used. Consider it a sort of /etc/hosts alternative provided on the command line.

### --retry <NUM> {#retry}
### --retry <NUM> {#retry}

Maximum number of retries, 0 for no retries, -1 for unlimited retries. Retry happens if any error occurs (asserts, captures, runtimes etc...).

Expand Down Expand Up @@ -380,7 +381,7 @@ Each variable is defined as name=value exactly as with [`--variable`](#variable)

Note that defining a variable twice produces an error.

### -v, --verbose {#verbose}
### --verbose {#verbose}

Turn on verbose output on standard error stream.
Useful for debugging.
Expand All @@ -397,7 +398,6 @@ Turn on more verbose output on standard error stream.

In contrast to [`--verbose`](#verbose) option, this option outputs the full HTTP body request and response on standard error. In addition, lines starting with '**' are libcurl debug logs.


### -h, --help {#help}

Usage help. This lists all current command line options with a short description.
Expand Down
8 changes: 8 additions & 0 deletions docs/spec/cmdline-opts-hurl/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Format all option files
bin/spec/cmdline-opts/format.py docs/spec/cmdline-opts-hurl/*.option

# Generate/Update clap command source file
bin/spec/cmdline-opts/generate_source.py docs/spec/cmdline-opts-hurl/*.option >packages/hurl/src/cli/options/commands.rs

# Generate/Update man options
bin/spec/cmdline-opts/generate_man.py docs/spec/cmdline-opts-hurl/*.option

0 comments on commit 64ce8c6

Please sign in to comment.