mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-09-11 05:35:53 +03:00
Add --progress option
This commit is contained in:
parent
726e46a53e
commit
6f2ec988ae
@ -260,6 +260,11 @@ Ignore the remaining of the file. It is useful for debugging a session.
|
||||
Write output to <file> instead of stdout.
|
||||
|
||||
|
||||
### --progress {#progress}
|
||||
|
||||
Print filename and status for each test
|
||||
|
||||
|
||||
### --summary {#summary}
|
||||
|
||||
Print test metrics at the end of the run
|
||||
|
@ -46,6 +46,7 @@ pub struct CliOptions {
|
||||
pub max_redirect: Option<usize>,
|
||||
pub no_proxy: Option<String>,
|
||||
pub output: Option<String>,
|
||||
pub progress: bool,
|
||||
pub proxy: Option<String>,
|
||||
pub summary: bool,
|
||||
pub timeout: Duration,
|
||||
@ -189,6 +190,11 @@ pub fn app() -> clap::App<'static, 'static> {
|
||||
.value_name("FILE")
|
||||
.help("Write to FILE instead of stdout"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::with_name("progress")
|
||||
.long("progress")
|
||||
.help("Print filename and status for each test"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::with_name("proxy")
|
||||
.short("x")
|
||||
@ -308,6 +314,7 @@ pub fn parse_options(matches: ArgMatches) -> Result<CliOptions, CliError> {
|
||||
};
|
||||
let no_proxy = matches.value_of("proxy").map(|x| x.to_string());
|
||||
let output = matches.value_of("output").map(|x| x.to_string());
|
||||
let progress = matches.is_present("progress");
|
||||
let proxy = matches.value_of("proxy").map(|x| x.to_string());
|
||||
let summary = matches.is_present("summary");
|
||||
let timeout = match matches.value_of("max_time") {
|
||||
@ -349,6 +356,7 @@ pub fn parse_options(matches: ArgMatches) -> Result<CliOptions, CliError> {
|
||||
max_redirect,
|
||||
no_proxy,
|
||||
output,
|
||||
progress,
|
||||
proxy,
|
||||
summary,
|
||||
timeout,
|
||||
|
@ -22,6 +22,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::time::Instant;
|
||||
|
||||
use atty::Stream;
|
||||
use colored::*;
|
||||
|
||||
use hurl::cli;
|
||||
use hurl::cli::{CliError, CliOptions};
|
||||
@ -70,6 +71,9 @@ fn execute(
|
||||
Some(filename.to_string())
|
||||
};
|
||||
|
||||
if cli_options.progress {
|
||||
eprintln!("{}: running", filename);
|
||||
}
|
||||
let log_parser_error =
|
||||
cli::make_logger_parser_error(lines.clone(), cli_options.color, optional_filename.clone());
|
||||
let log_runner_error =
|
||||
@ -172,7 +176,7 @@ fn execute(
|
||||
pre_entry,
|
||||
post_entry,
|
||||
};
|
||||
runner::run_hurl_file(
|
||||
let result = runner::run_hurl_file(
|
||||
hurl_file,
|
||||
&mut client,
|
||||
filename.to_string(),
|
||||
@ -180,7 +184,17 @@ fn execute(
|
||||
&log_verbose,
|
||||
&log_error_message,
|
||||
&log_runner_error,
|
||||
)
|
||||
);
|
||||
if cli_options.progress {
|
||||
let status = match (result.success, cli_options.color) {
|
||||
(true, true) => "success".green().to_string(),
|
||||
(true, false) => "success".to_string(),
|
||||
(false, true) => "failure".red().to_string(),
|
||||
(false, false) => "failure".to_string(),
|
||||
};
|
||||
eprintln!("{}: {}", filename, status);
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user