Use reference in function signatures.

This commit is contained in:
jcamiel 2022-05-18 11:07:09 +02:00 committed by Fabrice Reix
parent da8ae89281
commit af253975b0
3 changed files with 24 additions and 18 deletions

View File

@ -299,7 +299,7 @@ pub fn app(version: &str) -> Command {
)
}
pub fn parse_options(matches: ArgMatches) -> Result<CliOptions, CliError> {
pub fn parse_options(matches: &ArgMatches) -> Result<CliOptions, CliError> {
let cacert_file = match get_string(&matches, "cacert_file") {
None => None,
Some(filename) => {

View File

@ -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<Progress>,
@ -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,

View File

@ -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,