Skip to content

Commit

Permalink
Update options generator scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricereix authored and hurl-bot committed Jan 22, 2024
1 parent cda3770 commit 2a26671
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 50 deletions.
9 changes: 5 additions & 4 deletions bin/spec/options/generate_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
def generate_source(options: List[Option]):
s = COPYRIGHT
s += "\n" + "// Generated - Do not modify"
s += "\nuse clap::{value_parser, ArgAction};"
# s += "\nuse clap::{value_parser, ArgAction};"
s += """\n\npub fn input_files() -> clap::Arg {
clap::Arg::new("input_files")
.value_name("FILES")
Expand Down Expand Up @@ -63,13 +63,14 @@ def generate_source_option(option: Option):
s += f"\n .allow_hyphen_values(true)"
s += f'\n .help("{option.help}")'
if option.conflict is not None:
s += f'\n .conflicts_with("{option.conflict}")'
for conflict in option.conflict:
s += f'\n .conflicts_with("{conflict}")'
if option.value is not None:
s += f"\n .num_args(1)"
else:
s += f"\n .action(ArgAction::SetTrue)"
s += f"\n .action(clap::ArgAction::SetTrue)"
if option.append:
s += f"\n .action(ArgAction::Append)"
s += f"\n .action(clap::ArgAction::Append)"
if option.deprecated:
s += f"\n .hide(true)"
s += "\n}"
Expand Down
4 changes: 2 additions & 2 deletions bin/spec/options/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __str__(self):
if self.help is not None:
s += "\nhelp: " + self.help
if self.conflict is not None:
s += "\nconflict: " + self.conflict
s += "\nconflict: " + ", ".join(self.conflict)
if self.append:
s += "\nmulti: append"
if self.deprecated:
Expand Down Expand Up @@ -122,7 +122,7 @@ def parse(s):
elif key == "help":
help = v
elif key == "conflict":
conflict = v
conflict = [a.strip() for a in v.split(",")]
elif key == "multi":
if v == "append":
append = True
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/options/hurl/connect_timeout.option
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: connect_timeout
long: connect-timeout
value: SECONDS
value_default: 300
value_parser: value_parser!(u64)
value_parser: clap::value_parser!(u64)
help: Maximum time allowed for connection
---
Maximum time in seconds that you allow Hurl's connection to take.
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/options/hurl/delay.option
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: delay
long: delay
value: MILLISECONDS
value_default: 0
value_parser: value_parser!(u64)
value_parser: clap::value_parser!(u64)
help: Sets delay before each request.
---
Sets delay before each request.
2 changes: 1 addition & 1 deletion docs/spec/options/hurl/max_redirects.option
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: max_redirects
long: max-redirs
value: NUM
value_default: 50
value_parser: value_parser!(i32).range(-1..)
value_parser: clap::value_parser!(i32).range(-1..)
help: Maximum number of redirects allowed, -1 for unlimited redirects
---
Set maximum number of redirection-followings allowed
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/options/hurl/max_time.option
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ long: max-time
short: m
value: SECONDS
value_default: 300
value_parser: value_parser!(u64)
value_parser: clap::value_parser!(u64)
help: Maximum time allowed for the transfer
---
Maximum time in seconds that you allow a request/response to take. This is the standard timeout.
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/options/hurl/retry.option
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: retry
long: retry
value: NUM
value_default: 0
value_parser: value_parser!(i32).range(-1..)
value_parser: clap::value_parser!(i32).range(-1..)
help: Maximum number of retries, 0 for no retries, -1 for unlimited retries
---
Maximum number of retries, 0 for no retries, -1 for unlimited retries. Retry happens if any error occurs (asserts, captures, runtimes etc...).
2 changes: 1 addition & 1 deletion docs/spec/options/hurl/retry_interval.option
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: retry_interval
long: retry-interval
value: MILLISECONDS
value_default: 1000
value_parser: value_parser!(u64)
value_parser: clap::value_parser!(u64)
help: Interval in milliseconds before a retry
---
Duration in milliseconds between each retry. Default is 1000 ms.
2 changes: 1 addition & 1 deletion docs/spec/options/hurl/to_entry.option
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: to_entry
long: to-entry
value: ENTRY_NUMBER
value_parser: value_parser!(u32).range(1..)
value_parser: clap::value_parser!(u32).range(1..)
help: Execute Hurl file to ENTRY_NUMBER (starting at 1)
conflict: interactive
---
Expand Down
1 change: 1 addition & 0 deletions docs/spec/options/hurlfmt/check.option
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: check
long: check
help: Run in 'check' mode
conflict: format, output
---
Run in 'check' mode. Exits with 0 if input is formatted correctly, 1 otherwise.

Expand Down
1 change: 1 addition & 0 deletions docs/spec/options/hurlfmt/in_place.option
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: in_place
long: in-place
help: Modify files in place
conflict: output, color
---
Modify file in place.

Expand Down
1 change: 1 addition & 0 deletions docs/spec/options/hurlfmt/output_format.option
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ long: out
value: FORMAT
value_default: hurl
help: Specify output format: hurl, json or html
conflict: check
---
Specify output format: hurl, json or html.

0 comments on commit 2a26671

Please sign in to comment.