From 74534d14c4c4d3f8784e89725879d18bf181eeb6 Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sat, 19 Mar 2022 11:18:07 -0700 Subject: [PATCH 1/3] rename it, it was mardown, should be markdown --- .../{mardown_todo_rust => markdown_todo_rust}/Cargo.toml | 2 +- .../{mardown_todo_rust => markdown_todo_rust}/src/main.rs | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename 00_Utilities/{mardown_todo_rust => markdown_todo_rust}/Cargo.toml (85%) rename 00_Utilities/{mardown_todo_rust => markdown_todo_rust}/src/main.rs (100%) diff --git a/00_Utilities/mardown_todo_rust/Cargo.toml b/00_Utilities/markdown_todo_rust/Cargo.toml similarity index 85% rename from 00_Utilities/mardown_todo_rust/Cargo.toml rename to 00_Utilities/markdown_todo_rust/Cargo.toml index dbf4faa3..ff21c377 100644 --- a/00_Utilities/mardown_todo_rust/Cargo.toml +++ b/00_Utilities/markdown_todo_rust/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "mardown_todo_rust" +name = "markdown_todo_rust" version = "0.1.0" edition = "2021" diff --git a/00_Utilities/mardown_todo_rust/src/main.rs b/00_Utilities/markdown_todo_rust/src/main.rs similarity index 100% rename from 00_Utilities/mardown_todo_rust/src/main.rs rename to 00_Utilities/markdown_todo_rust/src/main.rs From 1d494e999a492e126a59a17323bd2c2fe2027810 Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sat, 19 Mar 2022 11:28:03 -0700 Subject: [PATCH 2/3] update the included languages --- 00_Utilities/markdown_todo_rust/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/00_Utilities/markdown_todo_rust/src/main.rs b/00_Utilities/markdown_todo_rust/src/main.rs index 827b45e0..f2f05fc4 100644 --- a/00_Utilities/markdown_todo_rust/src/main.rs +++ b/00_Utilities/markdown_todo_rust/src/main.rs @@ -12,11 +12,12 @@ use std::path::{Path, PathBuf}; //DATA const ROOT_DIR: &str = "../../"; -const LANGUAGES: [(&str,&str); 9] = [ //first element of tuple is the language name, second element is the file extension +const LANGUAGES: [(&str,&str); 10] = [ //first element of tuple is the language name, second element is the file extension ("csharp", "cs"), ("java", "java"), ("javascript", "html"), - ("pascal", "pas"), + ("kotlin", "kt"), + ("lua", "lua"), ("perl", "pl"), ("python", "py"), ("ruby", "rb"), From dc427a71dd494a466d4f8b51f3dd075c278c51ca Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sat, 19 Mar 2022 11:46:17 -0700 Subject: [PATCH 3/3] added another feature now shows how many games/languages are done for each language/game respectively --- 00_Utilities/markdown_todo_rust/src/main.rs | 140 ++++++++++++-------- 1 file changed, 86 insertions(+), 54 deletions(-) diff --git a/00_Utilities/markdown_todo_rust/src/main.rs b/00_Utilities/markdown_todo_rust/src/main.rs index f2f05fc4..d1f49bf4 100644 --- a/00_Utilities/markdown_todo_rust/src/main.rs +++ b/00_Utilities/markdown_todo_rust/src/main.rs @@ -82,34 +82,50 @@ fn main() { // for every game // every language + ✅/⬜️ for g in root_folders.into_iter() { - let game = g.clone().into_os_string().into_string().unwrap().chars().filter(|c| !(*c=='.' || *c=='/')).collect::();//get the game name - output_string += format!( - "### {}\n\n{}\n", //message format - game, - { - let mut s:String = String::new(); - //every language + ✅/⬜️ - LANGUAGES.iter().for_each(|lang| { - s+="- "; - s += lang.0; - // + ✅/⬜️ - let paths:Vec<_> = list_files(&g).into_iter().map(|path| path.into_os_string().into_string().unwrap()).collect(); - let paths:Vec = paths.into_iter().filter_map(|s| { - match Path::new(s.as_str()).extension().and_then(OsStr::to_str) { - None => None, - Some(s) => Some(s.to_string()), - } - }).collect(); //get all the extensions - if paths.into_iter().any(|f| f.eq(lang.1)) {//list_files(&game).iter().map(|path| path.into_os_string().into_string().unwrap()).any(|s| LANGUAGES.iter().map(|tup| Some(tup.1)).collect::>().contains(&s.split('.').next())) { - s+="✅"; - } else {s += "⬜️";} + //DATA + let mut num_done:u8 = 0; //number of languages implemented + let mut total:u8 = 0; //number of languages - s += "\n"; - }); - s - } + let game = g.clone().into_os_string().into_string().unwrap().chars().filter(|c| !(*c=='.' || *c=='/')).collect::();//get the game name + + + //find all the lanuages the game is coded in + let languages_list_for_game = { + let mut s:String = String::new(); + //every language + ✅/⬜️ + LANGUAGES.iter().for_each(|lang| { + s+="- "; + s += lang.0; + // + ✅/⬜️ + let paths:Vec<_> = list_files(&g).into_iter().map(|path| path.into_os_string().into_string().unwrap()).collect(); + let paths:Vec = paths.into_iter().filter_map(|s| { + match Path::new(s.as_str()).extension().and_then(OsStr::to_str) { + None => None, + Some(s) => Some(s.to_string()), + } + }).collect(); //get all the extensions + if paths.into_iter().any(|f| f.eq(lang.1)) {//list_files(&game).iter().map(|path| path.into_os_string().into_string().unwrap()).any(|s| LANGUAGES.iter().map(|tup| Some(tup.1)).collect::>().contains(&s.split('.').next())) { + s+="✅"; + num_done += 1; //increment number done + } else { + s += "⬜️"; + } + total += 1; //increment total + + s += "\n"; + }); + s + }; + + //format message + output_string += format!( + "### {}\t{}\n\n{}\n", //message format + game, + format!("coded in {}/{} languages", num_done, total), + languages_list_for_game, ).as_str(); } + //print the whole list println!("\n\n{}", output_string); } @@ -134,40 +150,56 @@ fn main() { // for every language // every game + ✅/⬜️ for lang in LANGUAGES.iter() { - output_string += format!( - "### {}\n\n{}\n", //message format - lang.0, - { - let mut s:String = String::new(); - for g in (&root_folders).into_iter() { - //data - let game = g.clone(); - let game_name = game.into_os_string().into_string().unwrap().chars().filter(|c| !(*c=='.' || *c=='/')).collect::(); //get the game name - let paths:Vec<_> = list_files(g).into_iter().map(|path| path.into_os_string().into_string().unwrap()).collect(); //all subpaths of game - let paths:Vec = paths.into_iter().filter_map(|s| { - match Path::new(s.as_str()).extension().and_then(OsStr::to_str) { - None => None, - Some(s) => Some(s.to_string()), - } - }).collect(); //get all the extensions + //DATA + let mut num_done = 0; + let mut total = 0; + let games_list_for_language = { //list + //DATA + let mut s:String = String::new(); - //add game name - s+="- "; - s+= game_name.as_str(); + //go through every game and check if it's coded in the language + for g in (&root_folders).into_iter() { + //data + let game = g.clone(); + let game_name = game.into_os_string().into_string().unwrap().chars().filter(|c| !(*c=='.' || *c=='/')).collect::(); //get the game name + let paths:Vec<_> = list_files(g).into_iter().map(|path| path.into_os_string().into_string().unwrap()).collect(); //all subpaths of game + let paths:Vec = paths.into_iter().filter_map(|s| { + match Path::new(s.as_str()).extension().and_then(OsStr::to_str) { + None => None, + Some(s) => Some(s.to_string()), + } + }).collect(); //get all the extensions - //every game + ✅/⬜️ - if paths.into_iter().any(|f| f.eq(lang.1)) { - s+="✅"; - } else {s += "⬜️";} + //add game name + s+="- "; + s+= game_name.as_str(); - s += "\n"; + //every game + ✅/⬜️ + if paths.into_iter().any(|f| f.eq(lang.1)) { + s+="✅"; + num_done += 1; //increment num done + } else { + s += "⬜️"; } - //print desired languages only - if langs_to_print.contains(&lang.1) { - print!("### {}\n\n{}",lang.0,s); - } - s + total += 1; //increment total + + //new line + s += "\n"; } + + //print desired languages only, what's output to std_out, also not markdown formatted + if langs_to_print.contains(&lang.1) { + print!("### {}\t{} ###\n{}\n\n", lang.0, format!("{}/{} games ported", num_done, total), s); + } + s + }; + + //format message, what's output to the file + output_string += format!( + "### {}\t{}\n\n{}\n\n", //message format + lang.0, //language + format!("{}/{} games ported", num_done, total),//number done / total number + games_list_for_language, ).as_str(); } }