Add cli-only info in option doc

This commit is contained in:
Fabrice Reix 2024-02-29 09:52:54 +01:00 committed by hurl-bot
parent 2433a24887
commit 6b927465fa
No known key found for this signature in database
GPG Key ID: 1283A2B4A0DCAF8D
11 changed files with 45 additions and 2 deletions

View File

@ -28,13 +28,16 @@ def generate_man_option(option: Option):
s += " {#%s}" % option.long.replace(".", "")
s += "\n\n"
s += option.description
if option.cli_only:
s += "\n\n"
s += "This is a cli-only option."
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 ...")
print("usage: generate_man.py OPTION_FILE1 OPTION_FILE2 ...")
sys.exit(1)
options = sorted(
[Option.parse_file(filename) for filename in sys.argv[1:]],

View File

@ -14,6 +14,7 @@ class Option:
help,
conflict,
append,
cli_only,
deprecated,
description,
):
@ -26,6 +27,7 @@ class Option:
self.help = help
self.conflict = conflict
self.append = append
self.cli_only = cli_only
self.deprecated = deprecated
self.description = description
@ -44,6 +46,7 @@ class Option:
and self.append == other.append
and self.deprecated == other.deprecated
and self.description == other.description
and self.cli_only == other.cli_only
)
def __str__(self):
@ -63,6 +66,8 @@ class Option:
s += "\nconflict: " + " ".join(self.conflict)
if self.append:
s += "\nmulti: append"
if self.cli_only:
s += "\ncli_only: true"
if self.deprecated:
s += "\ndeprecated: true"
s += "\n---"
@ -82,6 +87,7 @@ class Option:
self.conflict,
self.append,
self.description,
self.cli_only,
)
)
@ -96,6 +102,7 @@ class Option:
help = None
conflict = None
append = False
cli_only = False
deprecated = False
description = ""
in_description = False
@ -126,6 +133,13 @@ class Option:
elif key == "multi":
if v == "append":
append = True
elif key == "cli_only":
if v == "true":
cli_only = True
elif v == "false":
cli_only = False
else:
raise Exception("Expected true or false for cli attribute")
elif key == "deprecated":
if v == "true":
deprecated = True
@ -154,6 +168,7 @@ class Option:
help,
conflict,
append,
cli_only,
deprecated,
description.strip(),
)

View File

@ -121,7 +121,8 @@ More information on asserts can be found here [https://hurl.dev/docs/asserting-r
Options that exist in curl have exactly the same semantics.
Options specified on the command line are defined for every Hurl file's entry.
Options specified on the command line are defined for every Hurl file's entry,
except if they are tagged as cli-only (can not be defined in the Hurl request [Options] entry)
For instance:
@ -191,6 +192,8 @@ Note that this option does not affect the behavior with multiple input Hurl file
All the input files are executed independently. The result of one file does not affect the execution of the other Hurl files.
This is a cli-only option.
### -b, --cookie <FILE> {#cookie}
Read cookies from FILE (using the Netscape cookie file format).
@ -217,6 +220,8 @@ Control the format of error message (short by default or long)
Set root directory to import files in Hurl. This is used for files in multipart form data, request body and response output.
When it is not explicitly defined, files are relative to the current directory in which Hurl is running.
This is a cli-only option.
### --glob <GLOB> {#glob}
Specify input files that match the given glob pattern.
@ -224,6 +229,8 @@ Specify input files that match the given glob pattern.
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.
This is a cli-only option.
### -0, --http1.0 {#http10}
Tells Hurl to use HTTP version 1.0 instead of using its internally preferred HTTP version.
@ -347,18 +354,24 @@ Generate HTML report in DIR.
If the HTML report already exists, it will be updated with the new test results.
This is a cli-only option.
### --report-junit <FILE> {#report-junit}
Generate JUnit File.
If the FILE report already exists, it will be updated with the new test results.
This is a cli-only option.
### --report-tap <FILE> {#report-tap}
Generate TAP report.
If the FILE report already exists, it will be updated with the new test results.
This is a cli-only option.
### --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.
@ -379,11 +392,15 @@ Duration in milliseconds between each retry. Default is 1000 ms.
Activate test mode: with this, the HTTP response is not outputted anymore, progress is reported for each Hurl file tested, and a text summary is displayed when all files have been run.
This is a cli-only option.
### --to-entry <ENTRY_NUMBER> {#to-entry}
Execute Hurl file to ENTRY_NUMBER (starting at 1).
Ignore the remaining of the file. It is useful for debugging a session.
This is a cli-only option.
### --unix-socket <PATH> {#unix-socket}
(HTTP) Connect through this Unix domain socket, instead of using the network.

View File

@ -1,6 +1,7 @@
name: continue_on_error
long: continue-on-error
help: Continue executing requests even if an error occurs
cli_only: true
---
Continue executing requests to the end of the Hurl file even when an assert error occurs.
By default, Hurl exits after an assert error in the HTTP response.

View File

@ -2,6 +2,7 @@ name: file_root
long: file-root
value: DIR
help: Set root directory to import files [default: current directory]
cli_only: true
---
Set root directory to import files in Hurl. This is used for files in multipart form data, request body and response output.
When it is not explicitly defined, files are relative to the current directory in which Hurl is running.

View File

@ -3,6 +3,7 @@ long: glob
value: GLOB
help: Specify input files that match the given GLOB. Multiple glob flags may be used
multi: append
cli_only: true
---
Specify input files that match the given glob pattern.

View File

@ -2,6 +2,7 @@ name: report_html
long: report-html
value: DIR
help: Generate HTML report to DIR
cli_only: true
---
Generate HTML report in DIR.

View File

@ -2,6 +2,7 @@ name: report_junit
long: report-junit
value: FILE
help: Write a JUnit XML report to FILE
cli_only: true
---
Generate JUnit File.

View File

@ -2,6 +2,7 @@ name: report_tap
long: report-tap
value: FILE
help: Write a TAP report to FILE
cli_only: true
---
Generate TAP report.

View File

@ -1,5 +1,6 @@
name: test
long: test
help: Activate test mode
cli_only: true
---
Activate test mode: with this, the HTTP response is not outputted anymore, progress is reported for each Hurl file tested, and a text summary is displayed when all files have been run.

View File

@ -4,6 +4,7 @@ value: ENTRY_NUMBER
value_parser: clap::value_parser!(u32).range(1..)
help: Execute Hurl file to ENTRY_NUMBER (starting at 1)
conflict: interactive
cli_only: true
---
Execute Hurl file to ENTRY_NUMBER (starting at 1).
Ignore the remaining of the file. It is useful for debugging a session.