Skip to content

Commit

Permalink
Use reference in function signatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel authored and fabricereix committed Jun 19, 2022
1 parent da8ae89 commit af25397
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/hurl/src/cli/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
37 changes: 21 additions & 16 deletions packages/hurl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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());
}

Expand All @@ -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 => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -323,7 +328,7 @@ fn main() {
filename,
contents.clone(),
current_dir,
cli_options.clone(),
&cli_options,
&log_verbose,
&log_error_message,
progress,
Expand Down
3 changes: 2 additions & 1 deletion packages/hurl/src/runner/hurl_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -143,6 +143,7 @@ pub fn run(
.is_none();

let cookies = http_client.get_cookie_storage();
let filename = filename.to_string();
HurlResult {
filename,
entries,
Expand Down

0 comments on commit af25397

Please sign in to comment.