Skip to content

Commit

Permalink
Add --show-results option to run
Browse files Browse the repository at this point in the history
  • Loading branch information
giggio committed Nov 28, 2024
1 parent 9d6ee4b commit 7b49340
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ impl Args {
.long("simulate")
.help("Should simulate instead of running speed test"),
)
.arg(
Arg::with_name("show_results")
.long("show-results")
.help("Sends results to stdout, one result per line: download, upload, ping"),
)
.arg(
Arg::with_name("sender email")
.short("e")
Expand Down Expand Up @@ -258,6 +263,7 @@ impl Args {
("run", Some(run_args)) => Some(Command::Run(Run {
simulate: run_args.is_present("simulate"),
email_options: EmailOptions::new_from_args(run_args),
show_results: run_args.is_present("show_results"),
})),
("alert", Some(alert_args)) => Some(Command::Alert(Alert {
simulate: alert_args.is_present("simulate"),
Expand Down Expand Up @@ -289,6 +295,7 @@ impl Args {
pub struct Run {
pub simulate: bool,
pub email_options: Option<EmailOptions>,
pub show_results: bool,
}

#[derive(Debug)]
Expand Down
5 changes: 5 additions & 0 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ pub fn run(run: Run) -> Result<(), Option<String>> {
let result = convert_json(json_result)?;
write_to_result_file(&result)?;
append_to_summary_file(&result)?;
if run.show_results {
println!("{}", &result.download);
println!("{}", &result.upload);
println!("{}", &result.ping);
}
printlnv!("Got results:\n{:?}", &result);
Ok(())
}
Expand Down

0 comments on commit 7b49340

Please sign in to comment.