added list pokemon names and forms

This commit is contained in:
Vomitblood 2024-04-20 02:39:34 +08:00
parent 9e94599971
commit 9156ff8709
12 changed files with 7116 additions and 39595 deletions

23
.github/workflows/cargo.yml vendored Normal file
View file

@ -0,0 +1,23 @@
name: Cargo Build
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

View file

View file

@ -1,11 +0,0 @@
on: [push]
jobs:
build-and-publish:
runs-on: ubuntu-latest
name: My workflow
steps:
- name: Execute Action Graph
uses: actionforge/action@919d415a6b6e22919f7e115cf594ae52ded95041 # v0.8.31
with:
graph_file: testing.yml

147
Cargo.lock generated
View file

@ -84,9 +84,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.81" version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
[[package]] [[package]]
name = "arbitrary" name = "arbitrary"
@ -202,15 +202,15 @@ dependencies = [
[[package]] [[package]]
name = "built" name = "built"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d17f4d6e4dc36d1a02fbedc2753a096848e7c1b0772f7654eab8e2c927dd53" checksum = "41bfbdb21256b87a8b5e80fab81a8eed158178e812fd7ba451907518b2742f16"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.15.4" version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
@ -224,6 +224,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "byteorder-lite"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.6.0" version = "1.6.0"
@ -253,9 +259,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.90" version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@ -263,9 +269,9 @@ dependencies = [
[[package]] [[package]]
name = "cfg-expr" name = "cfg-expr"
version = "0.15.7" version = "0.15.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d" checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
dependencies = [ dependencies = [
"smallvec", "smallvec",
"target-lexicon", "target-lexicon",
@ -491,15 +497,15 @@ dependencies = [
[[package]] [[package]]
name = "either" name = "either"
version = "1.10.0" version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
version = "0.8.33" version = "0.8.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
@ -660,9 +666,9 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.12" version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -687,9 +693,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.3.25" version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
@ -706,9 +712,9 @@ dependencies = [
[[package]] [[package]]
name = "half" name = "half"
version = "2.4.0" version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"crunchy", "crunchy",
@ -841,11 +847,11 @@ dependencies = [
[[package]] [[package]]
name = "image-webp" name = "image-webp"
version = "0.1.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a84a25dcae3ac487bc24ef280f9e20c79c9b1a3e5e32cbed3041d1c514aa87c" checksum = "d730b085583c4d789dfd07fdcf185be59501666a90c97c40162b37e4fdad272d"
dependencies = [ dependencies = [
"byteorder", "byteorder-lite",
"thiserror", "thiserror",
] ]
@ -908,9 +914,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.28" version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -1328,9 +1334,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.79" version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -1371,9 +1377,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.35" version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -1682,18 +1688,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.197" version = "1.0.198"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.197" version = "1.0.198"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1835,9 +1841,9 @@ dependencies = [
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.11.0" version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]] [[package]]
name = "subtle" name = "subtle"
@ -1847,9 +1853,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.57" version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1947,9 +1953,9 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.34" version = "0.3.36"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
dependencies = [ dependencies = [
"deranged", "deranged",
"num-conv", "num-conv",
@ -2041,9 +2047,9 @@ dependencies = [
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.22.9" version = "0.22.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde", "serde",
@ -2309,7 +2315,7 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [ dependencies = [
"windows-targets 0.52.4", "windows-targets 0.52.5",
] ]
[[package]] [[package]]
@ -2329,17 +2335,18 @@ dependencies = [
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm 0.52.4", "windows_aarch64_gnullvm 0.52.5",
"windows_aarch64_msvc 0.52.4", "windows_aarch64_msvc 0.52.5",
"windows_i686_gnu 0.52.4", "windows_i686_gnu 0.52.5",
"windows_i686_msvc 0.52.4", "windows_i686_gnullvm",
"windows_x86_64_gnu 0.52.4", "windows_i686_msvc 0.52.5",
"windows_x86_64_gnullvm 0.52.4", "windows_x86_64_gnu 0.52.5",
"windows_x86_64_msvc 0.52.4", "windows_x86_64_gnullvm 0.52.5",
"windows_x86_64_msvc 0.52.5",
] ]
[[package]] [[package]]
@ -2350,9 +2357,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
@ -2362,9 +2369,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
@ -2374,9 +2381,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
@ -2386,9 +2399,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
@ -2398,9 +2411,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
@ -2410,9 +2423,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
@ -2422,15 +2435,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.52.4" version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.6.5" version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

35980
pokemon.json

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -1,2 +1,4 @@
pub mod constants; pub mod constants;
pub mod fetch; pub mod fetch;
pub mod list;
pub mod print;

60
src/list.rs Normal file
View file

@ -0,0 +1,60 @@
#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct Pokemon {
pokedex: String,
name: String,
forms: Vec<String>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct PokemonList {
pokemons: Vec<Pokemon>,
}
pub fn print_pokemon_list() -> Result<(), serde_json::Error> {
// open the file in read only mode with buffer
let file = std::fs::File::open(crate::constants::DATA_DIRECTORY.join("pokemon.json"))
.expect("File not found");
let reader = std::io::BufReader::new(file);
// parse json into pokemonlist struct
let pokemon_list: Vec<Pokemon> = serde_json::from_reader(reader)?;
// iterate through the vector and print the pokedex and name
for pokemon in pokemon_list {
println!("[{}] {}", pokemon.pokedex, pokemon.name);
}
println!("\nHint: Having trouble finding a Pokemon? Pass in --help to see tips!");
return Ok(());
}
pub fn print_pokemon_forms(pokemon_name: &str) -> std::io::Result<()> {
// open the file in read only mode with buffer
let file = std::fs::File::open(crate::constants::DATA_DIRECTORY.join("pokemon.json"))?;
let reader = std::io::BufReader::new(file);
// parse json into pokemonlist struct
let pokemon_list: Vec<Pokemon> = serde_json::from_reader(reader).expect("Failed to parse JSON");
// iterate through the list to find the specified pokemon and print its forms
let mut found = false;
for pokemon in pokemon_list {
// case insensitive comparison
if pokemon.name.eq_ignore_ascii_case(pokemon_name) {
println!("{} has the following forms:", pokemon.name);
for form in pokemon.forms {
println!(" - {}", form);
}
found = true;
break;
}
}
if !found {
println!("No Pokemon found with the name '{}'.", pokemon_name);
println!("Hint: Do `rustmon list` to see all available Pokemon.")
}
return Ok(());
}

View file

@ -4,12 +4,14 @@
- `extract_destination` - eXtract the colorscripts archive to a custom location - `extract_destination` - eXtract the colorscripts archive to a custom location
- `verbose` - Print colorscripts when generating - `verbose` - Print colorscripts when generating
## `list` - Print a list of Pokemon names and Pokedex number
- `forms` - Print a list of forms of the specified Pokemon
## `print` - Print a Pokemon colorscript ## `print` - Print a Pokemon colorscript
- `big` - Print a bigger version of the colorscript - `big` - Print a bigger version of the colorscript
- `id` - Print Pokemon by ID
- `list` - Print a list of all Pokemon names
- `name` - Print Pokemon by name - `name` - Print Pokemon by name
- `no-title` - Do not print Pokemon name - `no-title` - Do not print Pokemon name
- `pokedex` - Print Pokemon by Pokedex number
- `random` - Print a random Pokemon colorscript - `random` - Print a random Pokemon colorscript
- `shiny` - Print the shiny version of the colorscript - `shiny` - Print the shiny version of the colorscript
*/ */
@ -31,17 +33,45 @@ fn main() {
// invoke bigchungus fetch function // invoke bigchungus fetch function
rustmon::fetch::fetch(extract_destination, verbose) rustmon::fetch::fetch(extract_destination, verbose)
} else if let Some(list_args) = args.subcommand_matches("list") {
let pokemon_name: &String = list_args.get_one::<String>("forms").unwrap();
if pokemon_name.is_empty() {
// list
match rustmon::list::print_pokemon_list() {
Ok(_) => {}
Err(e) => {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
} else {
// list/forms
match rustmon::list::print_pokemon_forms(pokemon_name) {
Ok(_) => {}
Err(e) => {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
}
} else if let Some(print_args) = args.subcommand_matches("print") { } else if let Some(print_args) = args.subcommand_matches("print") {
// print // print
if let Some(name) = print_args.get_one::<String>("name") { // declare and define variables from arguments
// print/name let big: bool = print_args.get_flag("big");
println!("name: {}", name); let id = print_args.get_one::<String>("id").unwrap();
} let name = print_args.get_one::<String>("name").unwrap();
if print_args.get_flag("big") { let no_title: bool = print_args.get_flag("no-title");
// print/big let random: bool = print_args.get_flag("random");
println!("big"); let shiny: bool = print_args.get_flag("shiny");
}
println!("something else"); println!("Big: {}", big);
println!("ID: {}", id);
println!("Name: {}", name);
println!("No title: {}", no_title);
println!("Random: {}", random);
println!("Shiny: {}", shiny);
rustmon::print::print();
} }
} }
@ -65,40 +95,48 @@ fn argument_parser() -> clap::ArgMatches {
// fetch/verbose // fetch/verbose
.arg( .arg(
clap::Arg::new("verbose") clap::Arg::new("verbose")
.help("Select Pokemon by name") .help("Print colorscripts when generating")
.short('v') .short('v')
.long("verbose") .long("verbose")
.action(clap::ArgAction::SetTrue), .action(clap::ArgAction::SetTrue),
), ),
) )
// list subcommand
.subcommand(
clap::Command::new("list")
.about("Print a list of Pokemon names and Pokedex number")
// list/forms
.arg(
clap::Arg::new("forms")
.help("Print a list of forms of the specified Pokemon")
.short('f')
.long("forms")
.default_value(""),
)
.after_help(
"Tip: Use `grep` to search for a specific Pokemon form!
Example: `rustmon list | grep 'pikachu'`
For more advanced usage, use `less` or `more` to scroll through the list!",
),
)
// print subcommand // print subcommand
.subcommand( .subcommand(
clap::Command::new("print") clap::Command::new("print")
.about("Print a Pokemon colorscript") .about("Print a Pokemon colorscript")
// print/big // print/big
.arg( .arg(clap::arg!(-b --big "Print a bigger version of the colorscript"))
clap::arg!(-b --big "Print a bigger version of the colorscript")
.conflicts_with("list"),
)
// print/list
.arg(
clap::arg!(-l --list "Print a list of all Pokemon names")
.conflicts_with("name")
.conflicts_with("random"),
)
// print/name // print/name
.arg( .arg(
clap::Arg::new("name") clap::Arg::new("name")
.help("Select Pokemon by name") .help("Print Pokemon by name")
.short('n') .short('n')
.long("name") .long("name")
.conflicts_with("list") .conflicts_with("pokedex")
.conflicts_with("random"), .conflicts_with("random"),
) )
// print/random // print/random
.arg( .arg(
clap::arg!(-r --random "Print a random Pokemon colorscript") clap::arg!(-r --random "Print a random Pokemon colorscript")
.conflicts_with("list")
.conflicts_with("name"), .conflicts_with("name"),
) )
// print/no-title // print/no-title
@ -106,14 +144,19 @@ fn argument_parser() -> clap::ArgMatches {
clap::Arg::new("no-title") clap::Arg::new("no-title")
.help("Do not print Pokemon name") .help("Do not print Pokemon name")
.long("no-title") .long("no-title")
.action(clap::ArgAction::SetTrue) .action(clap::ArgAction::SetTrue),
.conflicts_with("list"), )
// print/pokedex
.arg(
clap::Arg::new("pokedex")
.help("Print Pokemon by Pokedex number")
.short('p')
.long("pokedex")
.conflicts_with("name")
.conflicts_with("random"),
) )
// print/shiny // print/shiny
.arg( .arg(clap::arg!(-s --shiny "Print the shiny version of the colorscript")),
clap::arg!(-s --shiny "Print the shiny version of the colorscript")
.conflicts_with("list"),
),
) )
// finalize // finalize
.get_matches(); .get_matches();