Skip to content

Commit 6b331d6

Browse files
authored
Merge pull request #78 from catap/only-the-best
Introduce `--only-the-best` option
2 parents 83bc79d + 0781533 commit 6b331d6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ pub struct Config {
251251
)]
252252
pub top_mirrors_number_to_retest: usize,
253253

254+
/// Only one, the best mirror
255+
#[arg(env = "RATE_MIRRORS_ONLY_THE_BEST", long)]
256+
pub only_the_best: bool,
257+
254258
/// Filename to save the output to in case of success
255259
#[arg(env = "RATE_MIRRORS_SAVE", long = "save", verbatim_doc_comment)]
256260
pub save_to_file: Option<String>,

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ impl<'a, T: LogFormatter> OutputSink<'a, T> {
9393

9494
fn main() -> Result<(), AppError> {
9595
let config = Arc::new(Config::parse());
96+
let only_the_best = config.only_the_best;
9697
if !config.allow_root && Uid::effective().is_root() {
9798
return Err(AppError::Root);
9899
}
@@ -157,8 +158,12 @@ fn main() -> Result<(), AppError> {
157158

158159
output.display_comment(format!("FINISHED AT: {}", Local::now()));
159160

160-
for result in results.into_iter() {
161-
output.display_mirror(&result.item);
161+
if only_the_best {
162+
output.display_mirror(&results.first().unwrap().item);
163+
} else {
164+
for result in results.into_iter() {
165+
output.display_mirror(&result.item);
166+
}
162167
}
163168
}
164169

0 commit comments

Comments
 (0)