diff --git a/packages/hurl/src/cli/options.rs b/packages/hurl/src/cli/options.rs index d72dcf5c8b9..f2ff628526e 100644 --- a/packages/hurl/src/cli/options.rs +++ b/packages/hurl/src/cli/options.rs @@ -299,7 +299,7 @@ pub fn app(version: &str) -> Command { ) } -pub fn parse_options(matches: ArgMatches) -> Result { +pub fn parse_options(matches: &ArgMatches) -> Result { let cacert_file = match get_string(&matches, "cacert_file") { None => None, Some(filename) => { diff --git a/packages/hurl/src/main.rs b/packages/hurl/src/main.rs index 884eeb2c58d..a86b6a6dcc5 100644 --- a/packages/hurl/src/main.rs +++ b/packages/hurl/src/main.rs @@ -86,7 +86,7 @@ fn execute( filename: &str, contents: String, current_dir: &Path, - cli_options: CliOptions, + cli_options: &CliOptions, log_verbose: &impl Fn(&str), log_error_message: &impl Fn(bool, &str), progress: Option, @@ -123,7 +123,7 @@ fn execute( if let Some(n) = cli_options.max_redirect { log_verbose(format!(" max redirect: {}", n).as_str()); } - if let Some(proxy) = cli_options.proxy.clone() { + if let Some(proxy) = &cli_options.proxy { log_verbose(format!(" proxy: {}", proxy).as_str()); } @@ -145,19 +145,19 @@ fn execute( } } - let cacert_file = cli_options.cacert_file; + let cacert_file = cli_options.cacert_file.clone(); let follow_location = cli_options.follow_location; let verbose = cli_options.verbose; let insecure = cli_options.insecure; let max_redirect = cli_options.max_redirect; - let proxy = cli_options.proxy; - let no_proxy = cli_options.no_proxy; - let cookie_input_file = cli_options.cookie_input_file; + let proxy = cli_options.proxy.clone(); + let no_proxy = cli_options.no_proxy.clone(); + let cookie_input_file = cli_options.cookie_input_file.clone(); let timeout = cli_options.timeout; let connect_timeout = cli_options.connect_timeout; - let user = cli_options.user; - let user_agent = cli_options.user_agent; + let user = cli_options.user.clone(); + let user_agent = cli_options.user_agent.clone(); let compressed = cli_options.compressed; let context_dir = match cli_options.file_root { None => { @@ -199,19 +199,24 @@ fn execute( } else { || false }; + let fail_fast = cli_options.fail_fast; + let variables = cli_options.variables.clone(); + let to_entry = cli_options.to_entry; + let context_dir = context_dir.to_path_buf(); + let ignore_asserts = cli_options.ignore_asserts; let options = RunnerOptions { - fail_fast: cli_options.fail_fast, - variables: cli_options.variables, - to_entry: cli_options.to_entry, - context_dir: context_dir.to_path_buf(), - ignore_asserts: cli_options.ignore_asserts, + fail_fast, + variables, + to_entry, + context_dir, + ignore_asserts, pre_entry, post_entry, }; let result = runner::run_hurl_file( hurl_file, &mut client, - filename.to_string(), + filename, &options, &log_verbose, &log_error_message, @@ -261,7 +266,7 @@ fn main() { let log_verbose = cli::make_logger_verbose(verbose); let color = cli::output_color(matches.clone()); let log_error_message = cli::make_logger_error_message(color); - let cli_options = unwrap_or_exit(cli::parse_options(matches.clone()), &log_error_message); + let cli_options = unwrap_or_exit(cli::parse_options(&matches), &log_error_message); let mut filenames = vec![]; if let Some(values) = cli::get_strings(&matches, "INPUT") { @@ -323,7 +328,7 @@ fn main() { filename, contents.clone(), current_dir, - cli_options.clone(), + &cli_options, &log_verbose, &log_error_message, progress, diff --git a/packages/hurl/src/runner/hurl_file.rs b/packages/hurl/src/runner/hurl_file.rs index 676d470f5b5..3b966c594f7 100644 --- a/packages/hurl/src/runner/hurl_file.rs +++ b/packages/hurl/src/runner/hurl_file.rs @@ -80,7 +80,7 @@ use super::entry; pub fn run( hurl_file: HurlFile, http_client: &mut http::Client, - filename: String, + filename: &str, options: &RunnerOptions, log_verbose: &impl Fn(&str), log_error_message: &impl Fn(bool, &str), @@ -143,6 +143,7 @@ pub fn run( .is_none(); let cookies = http_client.get_cookie_storage(); + let filename = filename.to_string(); HurlResult { filename, entries,