The personal anime and manga catalogue written in rust.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Changed '--get' to '--getstat' and added new '--get' command that prints the information about the given anime or manga.

willmexe 1525eacb 2a9bfc10

+152 -2
+68
Cargo.lock
··· 8 8 dependencies = [ 9 9 "edit", 10 10 "json", 11 + "strum", 12 + "strum_macros", 11 13 ] 12 14 13 15 [[package]] ··· 48 50 ] 49 51 50 52 [[package]] 53 + name = "heck" 54 + version = "0.4.0" 55 + source = "registry+https://github.com/rust-lang/crates.io-index" 56 + checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 57 + 58 + [[package]] 51 59 name = "instant" 52 60 version = "0.1.12" 53 61 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 75 83 checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" 76 84 77 85 [[package]] 86 + name = "proc-macro2" 87 + version = "1.0.36" 88 + source = "registry+https://github.com/rust-lang/crates.io-index" 89 + checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" 90 + dependencies = [ 91 + "unicode-xid", 92 + ] 93 + 94 + [[package]] 95 + name = "quote" 96 + version = "1.0.15" 97 + source = "registry+https://github.com/rust-lang/crates.io-index" 98 + checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" 99 + dependencies = [ 100 + "proc-macro2", 101 + ] 102 + 103 + [[package]] 78 104 name = "redox_syscall" 79 105 version = "0.2.10" 80 106 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 93 119 ] 94 120 95 121 [[package]] 122 + name = "rustversion" 123 + version = "1.0.6" 124 + source = "registry+https://github.com/rust-lang/crates.io-index" 125 + checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" 126 + 127 + [[package]] 128 + name = "strum" 129 + version = "0.24.0" 130 + source = "registry+https://github.com/rust-lang/crates.io-index" 131 + checksum = "e96acfc1b70604b8b2f1ffa4c57e59176c7dbb05d556c71ecd2f5498a1dee7f8" 132 + 133 + [[package]] 134 + name = "strum_macros" 135 + version = "0.24.0" 136 + source = "registry+https://github.com/rust-lang/crates.io-index" 137 + checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" 138 + dependencies = [ 139 + "heck", 140 + "proc-macro2", 141 + "quote", 142 + "rustversion", 143 + "syn", 144 + ] 145 + 146 + [[package]] 147 + name = "syn" 148 + version = "1.0.86" 149 + source = "registry+https://github.com/rust-lang/crates.io-index" 150 + checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" 151 + dependencies = [ 152 + "proc-macro2", 153 + "quote", 154 + "unicode-xid", 155 + ] 156 + 157 + [[package]] 96 158 name = "tempfile" 97 159 version = "3.3.0" 98 160 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 105 167 "remove_dir_all", 106 168 "winapi", 107 169 ] 170 + 171 + [[package]] 172 + name = "unicode-xid" 173 + version = "0.2.2" 174 + source = "registry+https://github.com/rust-lang/crates.io-index" 175 + checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 108 176 109 177 [[package]] 110 178 name = "which"
+3 -1
Cargo.toml
··· 7 7 8 8 [dependencies] 9 9 json = "*" 10 - edit = "*" 10 + edit = "*" 11 + strum = "0.24" 12 + strum_macros = "0.24"
+81 -1
src/main.rs
··· 5 5 use json::JsonValue; 6 6 use json::object; 7 7 use edit; 8 + use std::string::ToString; 9 + use strum_macros::Display; 8 10 9 11 use std::{ 10 12 io::Read, 11 13 }; 12 14 15 + #[derive(Display, Debug)] 13 16 enum SERIESSTATUS { 14 17 PLANNED, 15 18 WATCHING, ··· 18 21 DROPPED 19 22 } 20 23 24 + impl SERIESSTATUS { 25 + fn from_i8(value: i8) -> SERIESSTATUS { 26 + match value { 27 + 0 => SERIESSTATUS::PLANNED, 28 + 1 => SERIESSTATUS::WATCHING, 29 + 2 => SERIESSTATUS::COMPLETED, 30 + 3 => SERIESSTATUS::HOLD, 31 + 4 => SERIESSTATUS::DROPPED, 32 + _ => panic!("Unknown value: {}", value), 33 + } 34 + } 35 + } 36 + 37 + #[derive(Display, Debug)] 21 38 enum MOVIESTATUS { 22 39 PLANNED, 23 40 COMPLETED 24 41 } 25 42 43 + impl MOVIESTATUS { 44 + fn from_i8(value: i8) -> MOVIESTATUS { 45 + match value { 46 + 0 => MOVIESTATUS::PLANNED, 47 + 1 => MOVIESTATUS::COMPLETED, 48 + _ => panic!("Unknown value: {}", value), 49 + } 50 + } 51 + } 52 + 53 + #[derive(Display, Debug)] 26 54 enum MANGASTATUS { 27 55 PLANNED, 28 56 READING, 29 57 COMPLETED, 30 58 HOLD, 31 59 DROPPED 60 + } 61 + 62 + impl MANGASTATUS { 63 + fn from_i8(value: i8) -> MANGASTATUS { 64 + match value { 65 + 0 => MANGASTATUS::PLANNED, 66 + 1 => MANGASTATUS::READING, 67 + 2 => MANGASTATUS::COMPLETED, 68 + 3 => MANGASTATUS::HOLD, 69 + 4 => MANGASTATUS::DROPPED, 70 + _ => panic!("Unknown value: {}", value), 71 + } 72 + } 32 73 } 33 74 34 75 fn print_help() { ··· 65 106 println!(" --total, -t Total items in a category."); 66 107 println!(""); 67 108 println!("OPTIONS:"); 68 - println!(" --get <CATEGORY/--all> <STATISTIC> Get a statistic under `STATISTIC` for a specific category or everything."); 109 + println!(" --get <CATEGORY> <NAME> Get the information for a specific anime or manga in the catalogue."); 110 + println!(" --getstat <CATEGORY/--all> <STATISTIC> Get a statistic under `STATISTIC` for a specific category or everything."); 69 111 println!("x--getsort <CATEGORY/--all> <SORT> <?LENGTH/--all> Get a specific category or everything sorted by any of the methods under `SORT`."); 70 112 println!(" --add <CATEGORY> <NAME> <?RATING> <?STATUS> Add anime or manga to database with optional rating and status."); 71 113 println!(" --edit <CATEGORY> <NAME> Edit the notes for a specific anime or manga."); ··· 192 234 return Ok(()); 193 235 } 194 236 } else if args[1] == "--get" { 237 + if args.len() != 4 { 238 + print_help(); 239 + println!("Invalid number of arguments!"); 240 + return Ok(()); 241 + } 242 + 243 + if args[2] == "--series" || args[2] == "-s" { 244 + println!("Name:"); 245 + println!(" {}", data["series"][&args[3]]["name"]); 246 + println!("Rating:"); 247 + println!(" {}", data["series"][&args[3]]["rating"]); 248 + println!("Status:"); 249 + let status_int = String::from(&json::stringify(data["series"][&args[3]]["status"].clone())).parse::<i8>().unwrap(); 250 + println!(" {}", SERIESSTATUS::from_i8(status_int).to_string()); 251 + println!("Notes:"); 252 + println!(" {}", data["series"][&args[3]]["notes"]); 253 + } else if args[2] == "-mo" || args[2] == "--movie" || args[2] == "--movies" { 254 + println!("Name:"); 255 + println!(" {}", data["movies"][&args[3]]["name"]); 256 + println!("Rating:"); 257 + println!(" {}", data["movies"][&args[3]]["rating"]); 258 + println!("Status:"); 259 + let status_int = String::from(&json::stringify(data["movies"][&args[3]]["status"].clone())).parse::<i8>().unwrap(); 260 + println!(" {}", MOVIESTATUS::from_i8(status_int).to_string()); 261 + println!("Notes:"); 262 + println!(" {}", data["movies"][&args[3]]["notes"]); 263 + } else if args[2] == "-ma" || args[2] == "--manga" { 264 + println!("Name:"); 265 + println!(" {}", data["manga"][&args[3]]["name"]); 266 + println!("Rating:"); 267 + println!(" {}", data["manga"][&args[3]]["rating"]); 268 + println!("Status:"); 269 + let status_int = String::from(&json::stringify(data["manga"][&args[3]]["status"].clone())).parse::<i8>().unwrap(); 270 + println!(" {}", MANGASTATUS::from_i8(status_int).to_string()); 271 + println!("Notes:"); 272 + println!(" {}", data["manga"][&args[3]]["notes"]); 273 + } 274 + } else if args[1] == "--getstat" { 195 275 if args.len() != 4 { 196 276 print_help(); 197 277 println!("Invalid number of arguments!");