diff --git a/bin/spec/options/generate_man.py b/bin/spec/options/generate_man.py index 7749cd479..72bbecce8 100755 --- a/bin/spec/options/generate_man.py +++ b/bin/spec/options/generate_man.py @@ -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:]], diff --git a/bin/spec/options/option.py b/bin/spec/options/option.py index 0c4c4d943..57f6ab6ec 100644 --- a/bin/spec/options/option.py +++ b/bin/spec/options/option.py @@ -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(), ) diff --git a/docs/manual/hurl.md b/docs/manual/hurl.md index 4fcd9f080..b3bb4e1cd 100644 --- a/docs/manual/hurl.md +++ b/docs/manual/hurl.md @@ -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 {#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} 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 {#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 {#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 {#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 {#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 {#unix-socket} (HTTP) Connect through this Unix domain socket, instead of using the network. diff --git a/docs/spec/options/hurl/continue_on_error.option b/docs/spec/options/hurl/continue_on_error.option index ec22c590d..907f74818 100644 --- a/docs/spec/options/hurl/continue_on_error.option +++ b/docs/spec/options/hurl/continue_on_error.option @@ -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. diff --git a/docs/spec/options/hurl/file_root.option b/docs/spec/options/hurl/file_root.option index ca191a711..43b736777 100644 --- a/docs/spec/options/hurl/file_root.option +++ b/docs/spec/options/hurl/file_root.option @@ -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. diff --git a/docs/spec/options/hurl/glob.option b/docs/spec/options/hurl/glob.option index 7a1267b3d..96abf288c 100644 --- a/docs/spec/options/hurl/glob.option +++ b/docs/spec/options/hurl/glob.option @@ -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. diff --git a/docs/spec/options/hurl/report_html.option b/docs/spec/options/hurl/report_html.option index 4bc793a96..c4cbcb92b 100644 --- a/docs/spec/options/hurl/report_html.option +++ b/docs/spec/options/hurl/report_html.option @@ -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. diff --git a/docs/spec/options/hurl/report_junit.option b/docs/spec/options/hurl/report_junit.option index ea4f12bfb..40f739612 100644 --- a/docs/spec/options/hurl/report_junit.option +++ b/docs/spec/options/hurl/report_junit.option @@ -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. diff --git a/docs/spec/options/hurl/report_tap.option b/docs/spec/options/hurl/report_tap.option index 0a1a56c73..a8151f43d 100644 --- a/docs/spec/options/hurl/report_tap.option +++ b/docs/spec/options/hurl/report_tap.option @@ -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. diff --git a/docs/spec/options/hurl/test.option b/docs/spec/options/hurl/test.option index 3ab552765..e24eed601 100644 --- a/docs/spec/options/hurl/test.option +++ b/docs/spec/options/hurl/test.option @@ -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. diff --git a/docs/spec/options/hurl/to_entry.option b/docs/spec/options/hurl/to_entry.option index 1a52bf6a4..1d3dbef28 100644 --- a/docs/spec/options/hurl/to_entry.option +++ b/docs/spec/options/hurl/to_entry.option @@ -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.