Better display
This commit is contained in:
		
							
								
								
									
										17
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| use std::env; | use std::{env, fmt::Display}; | ||||||
|  |  | ||||||
| use clap; | use clap; | ||||||
| use log::{error, info, LevelFilter}; | use log::{error, info, LevelFilter}; | ||||||
| @@ -54,7 +54,7 @@ async fn main() { | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     let links = get_relative_links(&content); |     let links = get_relative_links(&content); | ||||||
|     info!("Found the following links: {}", links.join(", ")); |     info!("Found the following links: \n{}", join_long(&links)); | ||||||
|  |  | ||||||
|     for link_part in links { |     for link_part in links { | ||||||
|         let link = format!("{}{}", base_url, link_part); |         let link = format!("{}{}", base_url, link_part); | ||||||
| @@ -65,3 +65,16 @@ async fn main() { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | fn join_long<S: Display>(strings: &Vec<S>) -> String { | ||||||
|  |     let mut ret = String::new(); | ||||||
|  |     for (idx, s) in strings.iter().enumerate() { | ||||||
|  |         let mut to_push = format!(" {}: {}", idx + 1, s); | ||||||
|  |         if idx != strings.len() - 1 { | ||||||
|  |             to_push.push('\n'); | ||||||
|  |         } | ||||||
|  |         ret.push_str(&to_push); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     ret | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user