From fc428fddaf9173cd3b222e6240bb34d9486ff5d0 Mon Sep 17 00:00:00 2001 From: talwat <83217276+talwat@users.noreply.github.com> Date: Fri, 9 Aug 2024 12:04:52 +0300 Subject: [PATCH] docs: update the readme & comments --- README.md | 35 ++++++++++++++++++++--------------- src/cli.rs | 4 ++-- src/pokemon.rs | 7 +++++-- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7f27840..3adf2ec 100644 --- a/README.md +++ b/README.md @@ -8,35 +8,45 @@ A better rust version of pokeget. for more info, run `pokeget --help` -Also, if you're using pokeget in your bashrc, then instead of running `pokeget `, +Also, if you're using pokeget in your `.bashrc`, then instead of running `pokeget `, you can just write the output to a file by doing: `pokeget > file.txt` and then have something like `cat file.txt` bashrc. -You can also use multiple pokemon like: +You can also use multiple pokemon with names: -`pokeget bulbasaur pikachu` +`pokeget bulbasaur pikachu random` -and dex id's work too: +Or pokedex ID's: `pokeget 1 2 3` ## Installation -If you're on arch, you can use the AUR: +### Cargo *(recommended)* + +The recommended installation method is to use cargo: ```sh -yay -S pokeget +cargo install pokeget ``` -You can either use cargo by doing: +and making sure `$HOME/.cargo/bin` is added to `$PATH`. + +### AUR + +If you're on Arch, you can also use the AUR: ```sh -cargo install pokeget +yay -S pokeget ``` -and making sure `$HOME/.cargo/bin` is added to `$PATH`. +> [!WARNING] +> The AUR repository is currently unmaintained. +> If you'd like to maintain it, [open an issue](https://github.com/talwat/pokeget-rs/issues). -or clone the repository and compiling manually by doing: +### Git + +You can also clone the repository and compile manually by doing: ```sh git clone --recurse-submodules https://github.com/talwat/pokeget-rs.git @@ -86,11 +96,6 @@ It also is significantly (5.5x) faster than krabby which is another very similar For more info, go to [OTHER_PROJECTS.md](OTHER_PROJECTS.md). -## Where are the prebuilt binaries? - -I cannot figure out how to compile rust to multiple different platforms with a CI pipeline like github actions. -If someone knows how, PLEASE make a PR. - ## What about big sprites? Gone. Reduced to atoms. diff --git a/src/cli.rs b/src/cli.rs index 775d1af..b5457b5 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -42,7 +42,7 @@ pub struct Args { #[arg(long, default_value_t = false)] pub hisui: bool, - /// Display the noble variant of the pokemon, this option often times only works in tandom with --hisui. + /// Display the noble variant of the pokemon, this option often times only works in tandom with --hisui #[arg(short, long, default_value_t = false)] pub noble: bool, @@ -50,7 +50,7 @@ pub struct Args { #[arg(long, default_value_t = false)] pub galar: bool, - /// Display the female variant of the pokemon if it exists. This doesn't apply to nidoran, for some reason. + /// Display the female variant of the pokemon if it exists. This doesn't apply to nidoran, for some reason #[arg(long, default_value_t = false)] pub female: bool, } diff --git a/src/pokemon.rs b/src/pokemon.rs index 060b7bd..777df07 100644 --- a/src/pokemon.rs +++ b/src/pokemon.rs @@ -7,12 +7,13 @@ use rand::Rng; use crate::{cli::Args, Data}; /// Returns a random pokemon. -pub fn random(list: &[&str]) -> String { +fn random(list: &[&str]) -> String { let mut rand = rand::thread_rng(); String::from(list[rand.gen_range(0..list.len())]) } +/// Formats the pokemon name for display. fn format_name(name: String) -> String { name.replace('-', " ").replace('\'', "").to_title_case() } @@ -31,8 +32,10 @@ impl Selection { // If it's zero, then change it to random. 0 => Selection::Random, - // + // If it's not zero and in the range of the list, then it's a dex id. id if (id > 0 && id <= list.len()) => Selection::DexId(id - 1), + + // This shouldn't normally fire, but it's here to give the proper error message. _ => Selection::Name(id), }; } else {