├── .github └── workflows │ └── ci.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── Makefile ├── README.md ├── config.json ├── config_fi.json ├── rustfmt.toml └── src ├── api.rs ├── config_manager.rs ├── content_box.rs └── main.rs /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build octofetch 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | env: 6 | CARGO_TERM_COLOR: always 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Build 16 | run: cargo build --verbose --release;cp target/release/octofetch . 17 | - name: Run tests 18 | run: cargo test --verbose --release 19 | - name: Upload artifact 20 | uses: actions/upload-artifact@v1 21 | with: 22 | name: Build artifact 23 | path: octofetch -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "atty" 7 | version = "0.2.14" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 10 | dependencies = [ 11 | "hermit-abi", 12 | "libc", 13 | "winapi", 14 | ] 15 | 16 | [[package]] 17 | name = "autocfg" 18 | version = "1.0.1" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 21 | 22 | [[package]] 23 | name = "base64" 24 | version = "0.13.0" 25 | source = "registry+https://github.com/rust-lang/crates.io-index" 26 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 27 | 28 | [[package]] 29 | name = "bitflags" 30 | version = "1.3.2" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 33 | 34 | [[package]] 35 | name = "bumpalo" 36 | version = "3.7.1" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" 39 | 40 | [[package]] 41 | name = "bytes" 42 | version = "1.1.0" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" 45 | 46 | [[package]] 47 | name = "cc" 48 | version = "1.0.71" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" 51 | 52 | [[package]] 53 | name = "cfg-if" 54 | version = "1.0.0" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 57 | 58 | [[package]] 59 | name = "colored" 60 | version = "2.0.0" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" 63 | dependencies = [ 64 | "atty", 65 | "lazy_static", 66 | "winapi", 67 | ] 68 | 69 | [[package]] 70 | name = "core-foundation" 71 | version = "0.9.2" 72 | source = "registry+https://github.com/rust-lang/crates.io-index" 73 | checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" 74 | dependencies = [ 75 | "core-foundation-sys", 76 | "libc", 77 | ] 78 | 79 | [[package]] 80 | name = "core-foundation-sys" 81 | version = "0.8.3" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" 84 | 85 | [[package]] 86 | name = "crossterm" 87 | version = "0.22.1" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "c85525306c4291d1b73ce93c8acf9c339f9b213aef6c1d85c3830cbf1c16325c" 90 | dependencies = [ 91 | "bitflags", 92 | "crossterm_winapi", 93 | "libc", 94 | "mio", 95 | "parking_lot", 96 | "signal-hook", 97 | "signal-hook-mio", 98 | "winapi", 99 | ] 100 | 101 | [[package]] 102 | name = "crossterm_winapi" 103 | version = "0.9.0" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" 106 | dependencies = [ 107 | "winapi", 108 | ] 109 | 110 | [[package]] 111 | name = "encoding_rs" 112 | version = "0.8.28" 113 | source = "registry+https://github.com/rust-lang/crates.io-index" 114 | checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" 115 | dependencies = [ 116 | "cfg-if", 117 | ] 118 | 119 | [[package]] 120 | name = "fnv" 121 | version = "1.0.7" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 124 | 125 | [[package]] 126 | name = "foreign-types" 127 | version = "0.3.2" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 130 | dependencies = [ 131 | "foreign-types-shared", 132 | ] 133 | 134 | [[package]] 135 | name = "foreign-types-shared" 136 | version = "0.1.1" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 139 | 140 | [[package]] 141 | name = "form_urlencoded" 142 | version = "1.0.1" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 145 | dependencies = [ 146 | "matches", 147 | "percent-encoding", 148 | ] 149 | 150 | [[package]] 151 | name = "futures-channel" 152 | version = "0.3.17" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" 155 | dependencies = [ 156 | "futures-core", 157 | ] 158 | 159 | [[package]] 160 | name = "futures-core" 161 | version = "0.3.17" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" 164 | 165 | [[package]] 166 | name = "futures-sink" 167 | version = "0.3.17" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" 170 | 171 | [[package]] 172 | name = "futures-task" 173 | version = "0.3.17" 174 | source = "registry+https://github.com/rust-lang/crates.io-index" 175 | checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" 176 | 177 | [[package]] 178 | name = "futures-util" 179 | version = "0.3.17" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" 182 | dependencies = [ 183 | "autocfg", 184 | "futures-core", 185 | "futures-task", 186 | "pin-project-lite", 187 | "pin-utils", 188 | ] 189 | 190 | [[package]] 191 | name = "getrandom" 192 | version = "0.2.3" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" 195 | dependencies = [ 196 | "cfg-if", 197 | "libc", 198 | "wasi", 199 | ] 200 | 201 | [[package]] 202 | name = "h2" 203 | version = "0.3.6" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "6c06815895acec637cd6ed6e9662c935b866d20a106f8361892893a7d9234964" 206 | dependencies = [ 207 | "bytes", 208 | "fnv", 209 | "futures-core", 210 | "futures-sink", 211 | "futures-util", 212 | "http", 213 | "indexmap", 214 | "slab", 215 | "tokio", 216 | "tokio-util", 217 | "tracing", 218 | ] 219 | 220 | [[package]] 221 | name = "hashbrown" 222 | version = "0.11.2" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 225 | 226 | [[package]] 227 | name = "hermit-abi" 228 | version = "0.1.19" 229 | source = "registry+https://github.com/rust-lang/crates.io-index" 230 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 231 | dependencies = [ 232 | "libc", 233 | ] 234 | 235 | [[package]] 236 | name = "http" 237 | version = "0.2.5" 238 | source = "registry+https://github.com/rust-lang/crates.io-index" 239 | checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" 240 | dependencies = [ 241 | "bytes", 242 | "fnv", 243 | "itoa 0.4.8", 244 | ] 245 | 246 | [[package]] 247 | name = "http-body" 248 | version = "0.4.3" 249 | source = "registry+https://github.com/rust-lang/crates.io-index" 250 | checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5" 251 | dependencies = [ 252 | "bytes", 253 | "http", 254 | "pin-project-lite", 255 | ] 256 | 257 | [[package]] 258 | name = "httparse" 259 | version = "1.5.1" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" 262 | 263 | [[package]] 264 | name = "httpdate" 265 | version = "1.0.1" 266 | source = "registry+https://github.com/rust-lang/crates.io-index" 267 | checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" 268 | 269 | [[package]] 270 | name = "hyper" 271 | version = "0.14.13" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "15d1cfb9e4f68655fa04c01f59edb405b6074a0f7118ea881e5026e4a1cd8593" 274 | dependencies = [ 275 | "bytes", 276 | "futures-channel", 277 | "futures-core", 278 | "futures-util", 279 | "h2", 280 | "http", 281 | "http-body", 282 | "httparse", 283 | "httpdate", 284 | "itoa 0.4.8", 285 | "pin-project-lite", 286 | "socket2", 287 | "tokio", 288 | "tower-service", 289 | "tracing", 290 | "want", 291 | ] 292 | 293 | [[package]] 294 | name = "hyper-tls" 295 | version = "0.5.0" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" 298 | dependencies = [ 299 | "bytes", 300 | "hyper", 301 | "native-tls", 302 | "tokio", 303 | "tokio-native-tls", 304 | ] 305 | 306 | [[package]] 307 | name = "idna" 308 | version = "0.2.3" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 311 | dependencies = [ 312 | "matches", 313 | "unicode-bidi", 314 | "unicode-normalization", 315 | ] 316 | 317 | [[package]] 318 | name = "indexmap" 319 | version = "1.7.0" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" 322 | dependencies = [ 323 | "autocfg", 324 | "hashbrown", 325 | ] 326 | 327 | [[package]] 328 | name = "instant" 329 | version = "0.1.11" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "716d3d89f35ac6a34fd0eed635395f4c3b76fa889338a4632e5231a8684216bd" 332 | dependencies = [ 333 | "cfg-if", 334 | ] 335 | 336 | [[package]] 337 | name = "ipnet" 338 | version = "2.3.1" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" 341 | 342 | [[package]] 343 | name = "itoa" 344 | version = "0.4.8" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" 347 | 348 | [[package]] 349 | name = "itoa" 350 | version = "1.0.1" 351 | source = "registry+https://github.com/rust-lang/crates.io-index" 352 | checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" 353 | 354 | [[package]] 355 | name = "js-sys" 356 | version = "0.3.55" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" 359 | dependencies = [ 360 | "wasm-bindgen", 361 | ] 362 | 363 | [[package]] 364 | name = "lazy_static" 365 | version = "1.4.0" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 368 | 369 | [[package]] 370 | name = "libc" 371 | version = "0.2.103" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" 374 | 375 | [[package]] 376 | name = "lock_api" 377 | version = "0.4.5" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" 380 | dependencies = [ 381 | "scopeguard", 382 | ] 383 | 384 | [[package]] 385 | name = "log" 386 | version = "0.4.14" 387 | source = "registry+https://github.com/rust-lang/crates.io-index" 388 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 389 | dependencies = [ 390 | "cfg-if", 391 | ] 392 | 393 | [[package]] 394 | name = "matches" 395 | version = "0.1.9" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" 398 | 399 | [[package]] 400 | name = "memchr" 401 | version = "2.4.1" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 404 | 405 | [[package]] 406 | name = "mime" 407 | version = "0.3.16" 408 | source = "registry+https://github.com/rust-lang/crates.io-index" 409 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 410 | 411 | [[package]] 412 | name = "mio" 413 | version = "0.7.13" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" 416 | dependencies = [ 417 | "libc", 418 | "log", 419 | "miow", 420 | "ntapi", 421 | "winapi", 422 | ] 423 | 424 | [[package]] 425 | name = "miow" 426 | version = "0.3.7" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 429 | dependencies = [ 430 | "winapi", 431 | ] 432 | 433 | [[package]] 434 | name = "native-tls" 435 | version = "0.2.8" 436 | source = "registry+https://github.com/rust-lang/crates.io-index" 437 | checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" 438 | dependencies = [ 439 | "lazy_static", 440 | "libc", 441 | "log", 442 | "openssl", 443 | "openssl-probe", 444 | "openssl-sys", 445 | "schannel", 446 | "security-framework", 447 | "security-framework-sys", 448 | "tempfile", 449 | ] 450 | 451 | [[package]] 452 | name = "ntapi" 453 | version = "0.3.6" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" 456 | dependencies = [ 457 | "winapi", 458 | ] 459 | 460 | [[package]] 461 | name = "num_cpus" 462 | version = "1.13.0" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" 465 | dependencies = [ 466 | "hermit-abi", 467 | "libc", 468 | ] 469 | 470 | [[package]] 471 | name = "octofetch" 472 | version = "0.3.3" 473 | dependencies = [ 474 | "colored", 475 | "crossterm", 476 | "reqwest", 477 | "serde", 478 | "serde_json", 479 | "tokio", 480 | ] 481 | 482 | [[package]] 483 | name = "once_cell" 484 | version = "1.8.0" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" 487 | 488 | [[package]] 489 | name = "openssl" 490 | version = "0.10.36" 491 | source = "registry+https://github.com/rust-lang/crates.io-index" 492 | checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a" 493 | dependencies = [ 494 | "bitflags", 495 | "cfg-if", 496 | "foreign-types", 497 | "libc", 498 | "once_cell", 499 | "openssl-sys", 500 | ] 501 | 502 | [[package]] 503 | name = "openssl-probe" 504 | version = "0.1.4" 505 | source = "registry+https://github.com/rust-lang/crates.io-index" 506 | checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" 507 | 508 | [[package]] 509 | name = "openssl-sys" 510 | version = "0.9.67" 511 | source = "registry+https://github.com/rust-lang/crates.io-index" 512 | checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058" 513 | dependencies = [ 514 | "autocfg", 515 | "cc", 516 | "libc", 517 | "pkg-config", 518 | "vcpkg", 519 | ] 520 | 521 | [[package]] 522 | name = "parking_lot" 523 | version = "0.11.2" 524 | source = "registry+https://github.com/rust-lang/crates.io-index" 525 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 526 | dependencies = [ 527 | "instant", 528 | "lock_api", 529 | "parking_lot_core", 530 | ] 531 | 532 | [[package]] 533 | name = "parking_lot_core" 534 | version = "0.8.5" 535 | source = "registry+https://github.com/rust-lang/crates.io-index" 536 | checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" 537 | dependencies = [ 538 | "cfg-if", 539 | "instant", 540 | "libc", 541 | "redox_syscall", 542 | "smallvec", 543 | "winapi", 544 | ] 545 | 546 | [[package]] 547 | name = "percent-encoding" 548 | version = "2.1.0" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 551 | 552 | [[package]] 553 | name = "pin-project-lite" 554 | version = "0.2.7" 555 | source = "registry+https://github.com/rust-lang/crates.io-index" 556 | checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" 557 | 558 | [[package]] 559 | name = "pin-utils" 560 | version = "0.1.0" 561 | source = "registry+https://github.com/rust-lang/crates.io-index" 562 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 563 | 564 | [[package]] 565 | name = "pkg-config" 566 | version = "0.3.20" 567 | source = "registry+https://github.com/rust-lang/crates.io-index" 568 | checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" 569 | 570 | [[package]] 571 | name = "ppv-lite86" 572 | version = "0.2.14" 573 | source = "registry+https://github.com/rust-lang/crates.io-index" 574 | checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741" 575 | 576 | [[package]] 577 | name = "proc-macro2" 578 | version = "1.0.30" 579 | source = "registry+https://github.com/rust-lang/crates.io-index" 580 | checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" 581 | dependencies = [ 582 | "unicode-xid", 583 | ] 584 | 585 | [[package]] 586 | name = "quote" 587 | version = "1.0.10" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" 590 | dependencies = [ 591 | "proc-macro2", 592 | ] 593 | 594 | [[package]] 595 | name = "rand" 596 | version = "0.8.4" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" 599 | dependencies = [ 600 | "libc", 601 | "rand_chacha", 602 | "rand_core", 603 | "rand_hc", 604 | ] 605 | 606 | [[package]] 607 | name = "rand_chacha" 608 | version = "0.3.1" 609 | source = "registry+https://github.com/rust-lang/crates.io-index" 610 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 611 | dependencies = [ 612 | "ppv-lite86", 613 | "rand_core", 614 | ] 615 | 616 | [[package]] 617 | name = "rand_core" 618 | version = "0.6.3" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 621 | dependencies = [ 622 | "getrandom", 623 | ] 624 | 625 | [[package]] 626 | name = "rand_hc" 627 | version = "0.3.1" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" 630 | dependencies = [ 631 | "rand_core", 632 | ] 633 | 634 | [[package]] 635 | name = "redox_syscall" 636 | version = "0.2.10" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" 639 | dependencies = [ 640 | "bitflags", 641 | ] 642 | 643 | [[package]] 644 | name = "remove_dir_all" 645 | version = "0.5.3" 646 | source = "registry+https://github.com/rust-lang/crates.io-index" 647 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 648 | dependencies = [ 649 | "winapi", 650 | ] 651 | 652 | [[package]] 653 | name = "reqwest" 654 | version = "0.11.7" 655 | source = "registry+https://github.com/rust-lang/crates.io-index" 656 | checksum = "07bea77bc708afa10e59905c3d4af7c8fd43c9214251673095ff8b14345fcbc5" 657 | dependencies = [ 658 | "base64", 659 | "bytes", 660 | "encoding_rs", 661 | "futures-core", 662 | "futures-util", 663 | "http", 664 | "http-body", 665 | "hyper", 666 | "hyper-tls", 667 | "ipnet", 668 | "js-sys", 669 | "lazy_static", 670 | "log", 671 | "mime", 672 | "native-tls", 673 | "percent-encoding", 674 | "pin-project-lite", 675 | "serde", 676 | "serde_json", 677 | "serde_urlencoded", 678 | "tokio", 679 | "tokio-native-tls", 680 | "url", 681 | "wasm-bindgen", 682 | "wasm-bindgen-futures", 683 | "web-sys", 684 | "winreg", 685 | ] 686 | 687 | [[package]] 688 | name = "ryu" 689 | version = "1.0.5" 690 | source = "registry+https://github.com/rust-lang/crates.io-index" 691 | checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" 692 | 693 | [[package]] 694 | name = "schannel" 695 | version = "0.1.19" 696 | source = "registry+https://github.com/rust-lang/crates.io-index" 697 | checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" 698 | dependencies = [ 699 | "lazy_static", 700 | "winapi", 701 | ] 702 | 703 | [[package]] 704 | name = "scopeguard" 705 | version = "1.1.0" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 708 | 709 | [[package]] 710 | name = "security-framework" 711 | version = "2.4.2" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" 714 | dependencies = [ 715 | "bitflags", 716 | "core-foundation", 717 | "core-foundation-sys", 718 | "libc", 719 | "security-framework-sys", 720 | ] 721 | 722 | [[package]] 723 | name = "security-framework-sys" 724 | version = "2.4.2" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" 727 | dependencies = [ 728 | "core-foundation-sys", 729 | "libc", 730 | ] 731 | 732 | [[package]] 733 | name = "serde" 734 | version = "1.0.131" 735 | source = "registry+https://github.com/rust-lang/crates.io-index" 736 | checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" 737 | dependencies = [ 738 | "serde_derive", 739 | ] 740 | 741 | [[package]] 742 | name = "serde_derive" 743 | version = "1.0.131" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" 746 | dependencies = [ 747 | "proc-macro2", 748 | "quote", 749 | "syn", 750 | ] 751 | 752 | [[package]] 753 | name = "serde_json" 754 | version = "1.0.73" 755 | source = "registry+https://github.com/rust-lang/crates.io-index" 756 | checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" 757 | dependencies = [ 758 | "itoa 1.0.1", 759 | "ryu", 760 | "serde", 761 | ] 762 | 763 | [[package]] 764 | name = "serde_urlencoded" 765 | version = "0.7.0" 766 | source = "registry+https://github.com/rust-lang/crates.io-index" 767 | checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" 768 | dependencies = [ 769 | "form_urlencoded", 770 | "itoa 0.4.8", 771 | "ryu", 772 | "serde", 773 | ] 774 | 775 | [[package]] 776 | name = "signal-hook" 777 | version = "0.3.10" 778 | source = "registry+https://github.com/rust-lang/crates.io-index" 779 | checksum = "9c98891d737e271a2954825ef19e46bd16bdb98e2746f2eec4f7a4ef7946efd1" 780 | dependencies = [ 781 | "libc", 782 | "signal-hook-registry", 783 | ] 784 | 785 | [[package]] 786 | name = "signal-hook-mio" 787 | version = "0.2.1" 788 | source = "registry+https://github.com/rust-lang/crates.io-index" 789 | checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4" 790 | dependencies = [ 791 | "libc", 792 | "mio", 793 | "signal-hook", 794 | ] 795 | 796 | [[package]] 797 | name = "signal-hook-registry" 798 | version = "1.4.0" 799 | source = "registry+https://github.com/rust-lang/crates.io-index" 800 | checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 801 | dependencies = [ 802 | "libc", 803 | ] 804 | 805 | [[package]] 806 | name = "slab" 807 | version = "0.4.5" 808 | source = "registry+https://github.com/rust-lang/crates.io-index" 809 | checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" 810 | 811 | [[package]] 812 | name = "smallvec" 813 | version = "1.7.0" 814 | source = "registry+https://github.com/rust-lang/crates.io-index" 815 | checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" 816 | 817 | [[package]] 818 | name = "socket2" 819 | version = "0.4.2" 820 | source = "registry+https://github.com/rust-lang/crates.io-index" 821 | checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" 822 | dependencies = [ 823 | "libc", 824 | "winapi", 825 | ] 826 | 827 | [[package]] 828 | name = "syn" 829 | version = "1.0.80" 830 | source = "registry+https://github.com/rust-lang/crates.io-index" 831 | checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" 832 | dependencies = [ 833 | "proc-macro2", 834 | "quote", 835 | "unicode-xid", 836 | ] 837 | 838 | [[package]] 839 | name = "tempfile" 840 | version = "3.2.0" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" 843 | dependencies = [ 844 | "cfg-if", 845 | "libc", 846 | "rand", 847 | "redox_syscall", 848 | "remove_dir_all", 849 | "winapi", 850 | ] 851 | 852 | [[package]] 853 | name = "tinyvec" 854 | version = "1.5.0" 855 | source = "registry+https://github.com/rust-lang/crates.io-index" 856 | checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" 857 | dependencies = [ 858 | "tinyvec_macros", 859 | ] 860 | 861 | [[package]] 862 | name = "tinyvec_macros" 863 | version = "0.1.0" 864 | source = "registry+https://github.com/rust-lang/crates.io-index" 865 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 866 | 867 | [[package]] 868 | name = "tokio" 869 | version = "1.15.0" 870 | source = "registry+https://github.com/rust-lang/crates.io-index" 871 | checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" 872 | dependencies = [ 873 | "bytes", 874 | "libc", 875 | "memchr", 876 | "mio", 877 | "num_cpus", 878 | "pin-project-lite", 879 | "tokio-macros", 880 | "winapi", 881 | ] 882 | 883 | [[package]] 884 | name = "tokio-macros" 885 | version = "1.7.0" 886 | source = "registry+https://github.com/rust-lang/crates.io-index" 887 | checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" 888 | dependencies = [ 889 | "proc-macro2", 890 | "quote", 891 | "syn", 892 | ] 893 | 894 | [[package]] 895 | name = "tokio-native-tls" 896 | version = "0.3.0" 897 | source = "registry+https://github.com/rust-lang/crates.io-index" 898 | checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" 899 | dependencies = [ 900 | "native-tls", 901 | "tokio", 902 | ] 903 | 904 | [[package]] 905 | name = "tokio-util" 906 | version = "0.6.8" 907 | source = "registry+https://github.com/rust-lang/crates.io-index" 908 | checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" 909 | dependencies = [ 910 | "bytes", 911 | "futures-core", 912 | "futures-sink", 913 | "log", 914 | "pin-project-lite", 915 | "tokio", 916 | ] 917 | 918 | [[package]] 919 | name = "tower-service" 920 | version = "0.3.1" 921 | source = "registry+https://github.com/rust-lang/crates.io-index" 922 | checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" 923 | 924 | [[package]] 925 | name = "tracing" 926 | version = "0.1.29" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" 929 | dependencies = [ 930 | "cfg-if", 931 | "pin-project-lite", 932 | "tracing-core", 933 | ] 934 | 935 | [[package]] 936 | name = "tracing-core" 937 | version = "0.1.21" 938 | source = "registry+https://github.com/rust-lang/crates.io-index" 939 | checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" 940 | dependencies = [ 941 | "lazy_static", 942 | ] 943 | 944 | [[package]] 945 | name = "try-lock" 946 | version = "0.2.3" 947 | source = "registry+https://github.com/rust-lang/crates.io-index" 948 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" 949 | 950 | [[package]] 951 | name = "unicode-bidi" 952 | version = "0.3.7" 953 | source = "registry+https://github.com/rust-lang/crates.io-index" 954 | checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" 955 | 956 | [[package]] 957 | name = "unicode-normalization" 958 | version = "0.1.19" 959 | source = "registry+https://github.com/rust-lang/crates.io-index" 960 | checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" 961 | dependencies = [ 962 | "tinyvec", 963 | ] 964 | 965 | [[package]] 966 | name = "unicode-xid" 967 | version = "0.2.2" 968 | source = "registry+https://github.com/rust-lang/crates.io-index" 969 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 970 | 971 | [[package]] 972 | name = "url" 973 | version = "2.2.2" 974 | source = "registry+https://github.com/rust-lang/crates.io-index" 975 | checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 976 | dependencies = [ 977 | "form_urlencoded", 978 | "idna", 979 | "matches", 980 | "percent-encoding", 981 | ] 982 | 983 | [[package]] 984 | name = "vcpkg" 985 | version = "0.2.15" 986 | source = "registry+https://github.com/rust-lang/crates.io-index" 987 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 988 | 989 | [[package]] 990 | name = "want" 991 | version = "0.3.0" 992 | source = "registry+https://github.com/rust-lang/crates.io-index" 993 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 994 | dependencies = [ 995 | "log", 996 | "try-lock", 997 | ] 998 | 999 | [[package]] 1000 | name = "wasi" 1001 | version = "0.10.2+wasi-snapshot-preview1" 1002 | source = "registry+https://github.com/rust-lang/crates.io-index" 1003 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 1004 | 1005 | [[package]] 1006 | name = "wasm-bindgen" 1007 | version = "0.2.78" 1008 | source = "registry+https://github.com/rust-lang/crates.io-index" 1009 | checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" 1010 | dependencies = [ 1011 | "cfg-if", 1012 | "wasm-bindgen-macro", 1013 | ] 1014 | 1015 | [[package]] 1016 | name = "wasm-bindgen-backend" 1017 | version = "0.2.78" 1018 | source = "registry+https://github.com/rust-lang/crates.io-index" 1019 | checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" 1020 | dependencies = [ 1021 | "bumpalo", 1022 | "lazy_static", 1023 | "log", 1024 | "proc-macro2", 1025 | "quote", 1026 | "syn", 1027 | "wasm-bindgen-shared", 1028 | ] 1029 | 1030 | [[package]] 1031 | name = "wasm-bindgen-futures" 1032 | version = "0.4.28" 1033 | source = "registry+https://github.com/rust-lang/crates.io-index" 1034 | checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" 1035 | dependencies = [ 1036 | "cfg-if", 1037 | "js-sys", 1038 | "wasm-bindgen", 1039 | "web-sys", 1040 | ] 1041 | 1042 | [[package]] 1043 | name = "wasm-bindgen-macro" 1044 | version = "0.2.78" 1045 | source = "registry+https://github.com/rust-lang/crates.io-index" 1046 | checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" 1047 | dependencies = [ 1048 | "quote", 1049 | "wasm-bindgen-macro-support", 1050 | ] 1051 | 1052 | [[package]] 1053 | name = "wasm-bindgen-macro-support" 1054 | version = "0.2.78" 1055 | source = "registry+https://github.com/rust-lang/crates.io-index" 1056 | checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" 1057 | dependencies = [ 1058 | "proc-macro2", 1059 | "quote", 1060 | "syn", 1061 | "wasm-bindgen-backend", 1062 | "wasm-bindgen-shared", 1063 | ] 1064 | 1065 | [[package]] 1066 | name = "wasm-bindgen-shared" 1067 | version = "0.2.78" 1068 | source = "registry+https://github.com/rust-lang/crates.io-index" 1069 | checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" 1070 | 1071 | [[package]] 1072 | name = "web-sys" 1073 | version = "0.3.55" 1074 | source = "registry+https://github.com/rust-lang/crates.io-index" 1075 | checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" 1076 | dependencies = [ 1077 | "js-sys", 1078 | "wasm-bindgen", 1079 | ] 1080 | 1081 | [[package]] 1082 | name = "winapi" 1083 | version = "0.3.9" 1084 | source = "registry+https://github.com/rust-lang/crates.io-index" 1085 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1086 | dependencies = [ 1087 | "winapi-i686-pc-windows-gnu", 1088 | "winapi-x86_64-pc-windows-gnu", 1089 | ] 1090 | 1091 | [[package]] 1092 | name = "winapi-i686-pc-windows-gnu" 1093 | version = "0.4.0" 1094 | source = "registry+https://github.com/rust-lang/crates.io-index" 1095 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1096 | 1097 | [[package]] 1098 | name = "winapi-x86_64-pc-windows-gnu" 1099 | version = "0.4.0" 1100 | source = "registry+https://github.com/rust-lang/crates.io-index" 1101 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1102 | 1103 | [[package]] 1104 | name = "winreg" 1105 | version = "0.7.0" 1106 | source = "registry+https://github.com/rust-lang/crates.io-index" 1107 | checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" 1108 | dependencies = [ 1109 | "winapi", 1110 | ] 1111 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "octofetch" 3 | version = "0.3.3" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | reqwest = { version = "0.11.7", features = ["json"] } 10 | tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] } 11 | serde = { version = "1.0.131", features = ["derive"] } 12 | serde_json = "1.0.73" 13 | colored = "2.0.0" 14 | crossterm = "0.22.1" 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Natapat Samutpong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | help: 2 | @echo -e "Commands\n" 3 | @echo -e " build\t compile octofetch " 4 | @echo -e " install\t compile and install octofetch" 5 | build: 6 | @cargo build 7 | release: 8 | @cargo build --release 9 | install: 10 | @cargo install --path . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # octofetch 2 | 3 | ### Table of Contents 4 | 5 | 1. [Usage](#usage) 6 | 2. [Installation](#installation) 7 | 3. [Features](#features) 8 | 4. [FAQ](#faq) 9 | 10 | A CLI tool for fetching GitHub stats, kinda like `neofetch` 11 | 12 | 13 | 14 | # Usage 15 | 16 | `octofetch ` 17 | 18 | with custom config file 19 | 20 | `octofetch -c path\to\config ` 21 | 22 | # Installation 23 | 24 | ### Windows 25 | 26 | 1. Get the latest `.exe` file from [here](https://github.com/azur1s/octofetch/releases) 27 | 2. Place the file somewhere you can access and open terminal at that directory 28 | 3. Do `./octofetch.exe ` 29 | 4. Add to PATH variables for easier usage (optional) 30 | 31 | ### Local install with cargo 32 | 33 | Run `cargo install --git https://github.com/azur1s/octofetch` 34 | 35 | ### Manual install with cargo 36 | 37 | 1. Clone git repos: `git clone https://github.com/azur1s/octofetch` 38 | 2. Change directory: `cd octofetch` 39 | 3. Build binary `make build` or `cargo build` 40 | 4. Change directory to `./target/debug` and then run it! 41 | 42 | ### Linux 43 | 44 | [![Packaging status](https://repology.org/badge/vertical-allrepos/octofetch.svg)](https://repology.org/project/octofetch/versions) 45 | 46 | # Features 47 | 48 | fetch github user stats lol 49 | 50 | # FAQ 51 | 52 | ### Why rust? that language can also do the same thing! 53 | 54 | Yes, I agree with that but, This is my first project 55 | on rust and I might implement some more feature in the 56 | future too. Pretty proud of it ngl :D 57 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Header": " octofetch ", 3 | "Separator": ":", 4 | "Border": true, 5 | "MainColor": { "Red": 255, "Green": 0, "Blue": 255 }, 6 | "AccentColor": { "Red": 255, "Green": 255, "Blue": 255 }, 7 | "Keys": { 8 | "Login": "Username", 9 | "Name": "Name", 10 | "Bio": "Bio", 11 | "PublicRepos": "Repos", 12 | "PublicGists": "Gists", 13 | "Followers": "Followers", 14 | "Following": "Following", 15 | "HtmlUrl": "Url", 16 | "Blog": "Blog", 17 | "Location": "Location" 18 | } 19 | } -------------------------------------------------------------------------------- /config_fi.json: -------------------------------------------------------------------------------- 1 | { 2 | "Header": " Mustekalahaku ", 3 | "Separator": ":", 4 | "Border": true, 5 | "MainColor": { "Red": 255, "Green": 0, "Blue": 255 }, 6 | "AccentColor": { "Red": 255, "Green": 255, "Blue": 255 }, 7 | "Keys": { 8 | "Login": "Kayttajatunnus", 9 | "Name": "Nimi", 10 | "Bio": "Elamakerta", 11 | "PublicRepos": "Arkisto", 12 | "PublicGists": "Gists", 13 | "Followers": "Kannattaja", 14 | "Following": "Seuraaja", 15 | "HtmlUrl": "Url", 16 | "Blog": "Blogi", 17 | "Location": "Sijainti" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | hard_tabs = true 2 | tab_spaces = 4 -------------------------------------------------------------------------------- /src/api.rs: -------------------------------------------------------------------------------- 1 | // API 2 | use reqwest::header::USER_AGENT; 3 | 4 | // JSON stuff 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive(Serialize, Deserialize)] 8 | pub struct UserData { 9 | pub login: String, 10 | pub name: Option, 11 | pub bio: Option, 12 | pub public_repos: i64, 13 | pub public_gists: i64, 14 | pub followers: i64, 15 | pub following: i64, 16 | pub html_url: String, 17 | pub blog: String, 18 | pub location: Option, 19 | } 20 | 21 | const GITHUB_ENDPOINT: &str = "https://api.github.com/users/"; 22 | 23 | pub async fn get(username: String) -> Result> { 24 | let url = format!("{}{}", GITHUB_ENDPOINT, username); 25 | 26 | // Get the body of the request 27 | let client = reqwest::Client::new(); 28 | let res = client 29 | .get(url) 30 | .header(USER_AGENT, "octofetch cli") 31 | .send() 32 | .await? 33 | .text() 34 | .await?; 35 | // The json of the api's body 36 | let user: UserData = serde_json::from_str(&res)?; 37 | 38 | Ok(user) 39 | } 40 | -------------------------------------------------------------------------------- /src/config_manager.rs: -------------------------------------------------------------------------------- 1 | use serde::Deserialize; 2 | use std::error::Error; 3 | use std::fs; 4 | 5 | static DEFAULT_CONFIG: &str = r#" 6 | { 7 | "Header": " octofetch ", 8 | "Separator": ":", 9 | "Border": true, 10 | "MainColor": { "Red": 255, "Green": 0, "Blue": 255 }, 11 | "AccentColor": { "Red": 255, "Green": 255, "Blue": 255 }, 12 | "Keys": { 13 | "Login": "Username", 14 | "Name": "Name", 15 | "Bio": "Bio", 16 | "PublicRepos": "Repos", 17 | "PublicGists": "Gists", 18 | "Followers": "Followers", 19 | "Following": "Following", 20 | "HtmlUrl": "Url", 21 | "Blog": "Blog", 22 | "Location": "Location" 23 | } 24 | } 25 | "#; 26 | 27 | /// The structure of Octofetch config 28 | #[derive(Debug, Deserialize)] 29 | #[serde(rename_all = "PascalCase")] 30 | pub struct Config { 31 | /// The header on top of the border 32 | pub header: String, 33 | /// The separator between the key and value 34 | pub separator: String, 35 | /// Display the border or not 36 | pub border: bool, 37 | /// The main color across the program 38 | pub main_color: CustomColor, 39 | /// The accent color across the program 40 | pub accent_color: CustomColor, 41 | /// The key's texts 42 | pub keys: Keys, 43 | } 44 | 45 | /// The Custom color structure used to create custom color objects that can then be parsed for `crossterm::style::Color` 46 | #[derive(Debug, Deserialize)] 47 | #[serde(rename_all = "PascalCase")] 48 | pub struct CustomColor { 49 | /// Red (0 - 255) 50 | pub red: u8, 51 | /// Green (0 - 255) 52 | pub green: u8, 53 | /// Blue (0 - 255) 54 | pub blue: u8, 55 | } 56 | 57 | /// The key's text 58 | #[derive(Debug, Deserialize)] 59 | #[serde(rename_all = "PascalCase")] 60 | pub struct Keys { 61 | pub login: String, 62 | pub name: String, 63 | pub bio: String, 64 | pub public_repos: String, 65 | pub public_gists: String, 66 | pub followers: String, 67 | pub following: String, 68 | pub html_url: String, 69 | pub blog: String, 70 | pub location: String, 71 | } 72 | 73 | /// Loads a config from file and returns it. If load fails, an error is thrown. 74 | /// ### Arguments 75 | /// * `path` - Path to a custom config file 76 | pub fn load_config(path: Option<&str>) -> Result> { 77 | let str: String; 78 | if path == None { 79 | str = DEFAULT_CONFIG.to_string(); 80 | } else { 81 | str = fs::read_to_string(path.unwrap())?.parse()?; 82 | } 83 | let conf: Config = serde_json::from_str(&str)?; 84 | Ok(conf) 85 | } 86 | -------------------------------------------------------------------------------- /src/content_box.rs: -------------------------------------------------------------------------------- 1 | use std::{fmt, process}; 2 | 3 | pub struct ContentBox { 4 | pub header: String, 5 | pub pushed_lines: Vec, 6 | pub longest_line: usize, 7 | pub static_reduction: usize, 8 | pub border: bool, 9 | } 10 | 11 | impl fmt::Display for ContentBox { 12 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 13 | if self.border { 14 | if self.header.len() > self.longest_line - self.static_reduction { 15 | println!( 16 | "The header is too long for it to display, try reducing the header length." 17 | ); 18 | process::exit(1); 19 | } 20 | 21 | let dashes = "─"; 22 | let top = format!( 23 | "╭{}{}╮", 24 | self.header, 25 | dashes.repeat(self.longest_line + 3 - self.static_reduction - self.header.len()) 26 | ); 27 | 28 | writeln!(f, "{}", top)?; 29 | 30 | for pushed_line in self.pushed_lines.iter() { 31 | writeln!( 32 | f, 33 | "│ {}{} │", 34 | pushed_line, 35 | " ".repeat(self.longest_line - pushed_line.len() + 1) 36 | )?; 37 | } 38 | 39 | writeln!( 40 | f, 41 | "╰{}╯", 42 | dashes.repeat(self.longest_line + 3 - self.static_reduction) 43 | ) 44 | } else { 45 | for pushed_line in self.pushed_lines.iter() { 46 | writeln!(f, "{}", pushed_line)?; 47 | } 48 | 49 | writeln!(f) 50 | } 51 | } 52 | } 53 | 54 | impl ContentBox { 55 | pub fn push(&mut self, line: String) { 56 | let new_line = line.len(); 57 | self.pushed_lines.push(line); 58 | if new_line > self.longest_line { 59 | self.longest_line = new_line; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use config_manager::CustomColor; 2 | use crossterm::style::{Color, ResetColor, SetForegroundColor}; 3 | use std::process; 4 | 5 | mod api; 6 | mod config_manager; 7 | mod content_box; 8 | 9 | /// Parses a string with predetermined colors 10 | /// ### Arguments 11 | /// 12 | /// * `key` - The key of the value 13 | /// * `text` - The content 14 | /// * `key_color` - The foreground color of the key 15 | /// * `text_color` - The foreground color of the content 16 | /// 17 | fn colorful_format( 18 | key: &str, 19 | text: &String, 20 | separator: &String, 21 | key_color: Color, 22 | text_color: Color, 23 | ) -> String { 24 | // One would preferably want to use colors that are ANSI to avoid 25 | // issues with older/primitive terminals with limited color support 26 | let main_color = SetForegroundColor(key_color); 27 | let acccent_color = SetForegroundColor(text_color); 28 | return format!( 29 | "{}{}{} {}{}{}", 30 | main_color, key, separator, acccent_color, text, ResetColor 31 | ); 32 | } 33 | 34 | /// Parses a color from the CustomColor and returns Color 35 | /// ### Arguments 36 | /// * `color` - The CustomColor to be parsed 37 | fn parse_color(color: CustomColor) -> Color { 38 | return Color::Rgb { 39 | r: color.red, 40 | g: color.green, 41 | b: color.blue, 42 | }; 43 | } 44 | 45 | /// Gets the amount of digits the rgb values have in total and returns it 46 | /// ### Arguments 47 | /// * `color` - The CustomColor object where the rgb values are fetched 48 | fn color_char_count(color: &CustomColor) -> usize { 49 | let mut char_count = 0; 50 | char_count += color.red.to_string().len(); 51 | char_count += color.green.to_string().len(); 52 | char_count += color.blue.to_string().len(); 53 | return char_count; 54 | } 55 | 56 | const HELP_MESSAGE: &str = "\ 57 | Usage: 58 | octofetch 59 | Other: 60 | -v Print version and exit. 61 | -h Print help and exit. 62 | -c Loads a custom config file 63 | "; 64 | 65 | #[tokio::main] 66 | async fn main() -> Result<(), Box> { 67 | if std::env::args().nth(1) == None { 68 | eprintln!("No username given, use for more info."); 69 | process::exit(1); 70 | } 71 | // Get the first argument 72 | let user_to_search = std::env::args() 73 | .nth(1) 74 | .expect("No username given, use for more info."); 75 | 76 | if user_to_search.is_empty() { 77 | process::exit(1); 78 | } 79 | 80 | let mut config_path: Option<&str> = None; 81 | 82 | // TODO: create pipeline for multiple arguments 83 | let args: Vec = std::env::args().collect(); 84 | let mut index: usize = 0; 85 | while args.len() > index { 86 | let arg: &str = &args[index]; 87 | match arg { 88 | "-v" => { 89 | const VERSION: &str = env!("CARGO_PKG_VERSION"); 90 | println!("octofetch v{}", VERSION); 91 | process::exit(0); 92 | } 93 | "-h" => { 94 | print!("{}", HELP_MESSAGE); 95 | process::exit(0); 96 | } 97 | "-c" => { 98 | index = index + 1; 99 | if index < args.len() { 100 | config_path = Some(&args[index]); 101 | index = index + 1; 102 | } else { 103 | println!("No config path specified, use for more info. Using default config."); 104 | } 105 | } 106 | _ => index = index + 1, 107 | } 108 | } 109 | 110 | let user = api::get(user_to_search).await?; 111 | 112 | if user.login.is_empty() { 113 | println!("User not found"); 114 | process::exit(0); 115 | } 116 | 117 | // Load the config from file 118 | let config = config_manager::load_config(config_path)?; 119 | let separator = &config.separator; 120 | // Parse the colors 121 | let total_chars = color_char_count(&config.main_color) + color_char_count(&config.accent_color); 122 | let main_color = parse_color(config.main_color); 123 | let accent_color = parse_color(config.accent_color); 124 | 125 | // The fetch 126 | let mut info = content_box::ContentBox { 127 | header: config.header, 128 | pushed_lines: Vec::new(), 129 | longest_line: 0, 130 | static_reduction: 24 + total_chars, 131 | border: config.border, 132 | }; 133 | 134 | info.push(colorful_format( 135 | &config.keys.login, 136 | &user.login, 137 | separator, 138 | main_color, 139 | accent_color, 140 | )); 141 | if user.bio != None { 142 | info.push(colorful_format( 143 | &config.keys.bio, 144 | &user.bio.unwrap(), 145 | separator, 146 | main_color, 147 | accent_color, 148 | )); 149 | } 150 | info.push(colorful_format( 151 | &config.keys.public_repos, 152 | &user.public_repos.to_string(), 153 | separator, 154 | main_color, 155 | accent_color, 156 | )); 157 | info.push(colorful_format( 158 | &config.keys.public_gists, 159 | &user.public_gists.to_string(), 160 | separator, 161 | main_color, 162 | accent_color, 163 | )); 164 | info.push(colorful_format( 165 | &config.keys.followers, 166 | &user.followers.to_string(), 167 | separator, 168 | main_color, 169 | accent_color, 170 | )); 171 | info.push(colorful_format( 172 | &config.keys.following, 173 | &user.following.to_string(), 174 | separator, 175 | main_color, 176 | accent_color, 177 | )); 178 | if user.location != None { 179 | info.push(colorful_format( 180 | &config.keys.location, 181 | &user.location.unwrap(), 182 | separator, 183 | main_color, 184 | accent_color, 185 | )); 186 | } 187 | if user.blog != "" { 188 | info.push(colorful_format( 189 | &config.keys.blog, 190 | &user.blog, 191 | separator, 192 | main_color, 193 | accent_color, 194 | )); 195 | } else { 196 | info.push(colorful_format( 197 | &config.keys.html_url, 198 | &user.html_url, 199 | separator, 200 | main_color, 201 | accent_color, 202 | )); 203 | } 204 | 205 | println!("{}", info.to_string().trim_end()); 206 | 207 | Ok(()) 208 | } 209 | --------------------------------------------------------------------------------