From e452b311a0f49b7916970bae95fc59e55cb4196e Mon Sep 17 00:00:00 2001 From: callmeclover Date: Mon, 24 Jun 2024 09:52:57 -0400 Subject: [PATCH] Verbosify code by adding doc comments. --- CHANGELOG.md | 6 +++--- README.md | 8 +------- TODO.md | 9 ++++++--- src/config.rs | 13 +++++++++---- src/func.rs | 21 +++++++++++++++++---- src/main.rs | 4 ++++ 6 files changed, 40 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bcec4f..d53ea05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -## [1.0.0] - 2024-05-30 +## [1.0.1] - 2024-06-24 -- [x] officially support osx and linux +- [x] add doc comments -11:07:34 PM, 5/30/2024 (UTC-5) \ No newline at end of file +9:52:22 AM, 6/24/2024 (UTC-5) \ No newline at end of file diff --git a/README.md b/README.md index ae86c56..c869c87 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ currently, there are 3 versions (not including crosses of any): **the `advanced` feature requires administrator privileges. this is why it is seperate from `default`. it also depends on the `windows` crate, so it does not support linux/macos.** -**the `invisibility` feature has no console window, so it cannot be regularly exited out of. see [this notice](#other-little-notice) for info on killing a hidden instance.** +**the `invisibility` feature has no console window, so it cannot be regularly exited out of. you'll need to kill its process.** i will also not be publishing any invisible or advanced builds for jerry beyond [v0.3.4](https://github.com/callmeclover/jerry/releases/tag/v0.3.4) and [v1.0.0](https://github.com/callmeclover/jerry/releases/tag/v1.0.0) respectively. build them yourself with `cargo build --features invisible` or `cargo build --features advanced`. @@ -25,12 +25,6 @@ i will also not be publishing any invisible or advanced builds for jerry beyond i, @callmeclover, hold 0 responsibility over what this thing does, [**especially forks**](#on-the-topic-of-forks). you are on your own if he does anything bad. -## other little notice - -the invisible version hides the console window, so you need to kill his process in task manager if he gets out of hand. - -he doesn't cloak himself, so his process name is `jerry.exe`. - ## on the topic of forks jerry is, technically, considered malware. as the [wiki page](https://wikipedia.com/wiki/Malware) states, _"[Malware] is any software intentionally designed to cause disruption to a computer, server, client, or computer network,"_ which is exactly what jerry does. diff --git a/TODO.md b/TODO.md index 8d88638..1cae8c0 100644 --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,11 @@ -- [ ] testing +- [x] v1.0.0 testing - [x] windows tests - - [ ] linux tests + - [x] linux tests - [x] macos tests - [ ] platform parity - [x] windows - [ ] linux - - [ ] macos \ No newline at end of file + - [ ] macos +- [ ] verbosify code + - [x] add doc comments + - [ ] add comments everywhere else \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 3b57d1c..d176713 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,20 +1,22 @@ use cached::proc_macro::cached; -#[allow(unused_imports)] -use dialoguer::{theme::ColorfulTheme, Confirm}; use serde::{Deserialize, Serialize}; use std::{fs, path::Path}; use toml::{de::Error, from_str, to_string_pretty}; +#[cfg(not(feature = "invisibility"))] +use dialoguer::{theme::ColorfulTheme, Confirm}; #[derive(Debug, Serialize, Deserialize, Default, Clone, Eq, Hash, PartialEq)] +/// Jerry's config struct. pub struct Config { - #[allow(dead_code)] // Disable dead code warning for the entire struct + #[allow(dead_code)] basic: Basic, - #[allow(dead_code)] // Disable dead code warning for the entire struct + #[allow(dead_code)] pub extra: Extra, } #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] #[allow(clippy::struct_excessive_bools)] +/// Basic options, like whether to enable keyboard inputs or not. struct Basic { #[allow(dead_code)] use_mouse: bool, @@ -34,6 +36,7 @@ struct Basic { #[derive(Debug, Serialize, Deserialize, Default, Clone, Hash, PartialEq, Eq)] #[allow(clippy::struct_excessive_bools)] +/// Extra options, like whether to use an external sentence api or not. pub struct Extra { #[allow(dead_code)] pub do_debugging: bool, @@ -67,6 +70,7 @@ impl Default for Basic { } #[cached] +/// Attempt to read a config file, or create one. pub fn get_config() -> Config { loop { if Path::new("./config.toml").exists() { @@ -129,6 +133,7 @@ pub fn get_config() -> Config { } } +/// Get a vector of possible inputs from a Config object. pub fn get_options(config: &Config) -> Vec<(&'static str, usize)> { let mut options: Vec<(&'static str, usize)> = vec![]; diff --git a/src/func.rs b/src/func.rs index 7f1a7ef..ef6db45 100644 --- a/src/func.rs +++ b/src/func.rs @@ -38,6 +38,7 @@ lazy_static! { static ref IS_RCTRL_PRESSED: Mutex = Mutex::new(false); } +/// Toggle the value of a modifier key. fn toggle_key_press(key: Key, enigo: &mut Enigo) { let kvalue = !*(match key { Key::Shift => IS_SHIFT_PRESSED.lock().unwrap(), @@ -56,6 +57,7 @@ fn toggle_key_press(key: Key, enigo: &mut Enigo) { } } +/// Drag the mouse to `pos`. pub fn drag_mouse_abs(enigo: &mut Enigo, pos: (i32, i32), speed: Speed) { let (mouse_x, mouse_y) = enigo.location().expect("Unable to locate mouse position."); @@ -81,6 +83,7 @@ pub fn drag_mouse_abs(enigo: &mut Enigo, pos: (i32, i32), speed: Speed) { } } +/// Drag the mouse relatively to `pos`. pub fn drag_mouse_rel(enigo: &mut Enigo, pos: (i32, i32), speed: Speed) { let delta_sum = (pos.0.pow(2) + pos.1.pow(2)) as f32; let distance = delta_sum.sqrt(); @@ -102,6 +105,7 @@ pub fn drag_mouse_rel(enigo: &mut Enigo, pos: (i32, i32), speed: Speed) { } } +/// Convert a string to a mouse button. fn convert_mouse_action(input: &str) -> Option