From 1e96fa989def43b2ee2aac7c194faddd05f6a09b Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 28 Jan 2022 21:18:05 +0000 Subject: [PATCH 1/7] Ensure that files are not overwritten when uwu'ifying --- src/main.rs | 4 ++-- src/uwuify.rs | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7c3f6f4..a4cad31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,11 +13,11 @@ struct Args { text: Option, /// The file to uwu'ify - #[clap(short, long, parse(from_os_str), conflicts_with = "text", requires = "outfile", value_name = "FILE", display_order = 2)] + #[clap(short, long, parse(from_os_str), conflicts_with = "text", requires = "outfile", value_name = "FILE", value_hint = clap::ValueHint::FilePath, display_order = 2)] infile: Option, /// The file to output uwu'ified text - #[clap(short, long, value_name = "FILE", display_order = 3)] + #[clap(short, long, value_name = "FILE", value_hint = clap::ValueHint::FilePath, display_order = 3)] outfile: Option, /// The modifier to determine how many words to be uwu'ified diff --git a/src/uwuify.rs b/src/uwuify.rs index bd56fb4..173fc74 100644 --- a/src/uwuify.rs +++ b/src/uwuify.rs @@ -1,4 +1,4 @@ -use std::io::Error; +use std::error::Error; use std::path::PathBuf; use linkify::{LinkFinder, LinkKind}; @@ -59,22 +59,27 @@ impl UwUify { } } - pub fn uwuify(&self) -> Result<(), Error> { + pub fn uwuify(&self) -> Result<(), Box> { // Handle Text if !self.text.is_empty() { let uwu_text = self.uwuify_sentence(&self.text); // Handle Text Output if !self.output.is_empty() { + if UwUOutFile::exists(&self.output) { + return Err(format!("File '{}' already exists, aborting operation", &self.output).into()); + } + let mut uwu_out_file = match UwUOutFile::new(&self.output) { Ok(uwu_out_file) => uwu_out_file, - Err(err) => return Err(err) + Err(err) => return Err(err.into()) }; + let mut uwu_progress_bar = UwUProgressBar::new(uwu_text.len() as u64); match uwu_out_file.write_string(&uwu_text) { Ok(_) => (), - Err(err) => return Err(err), + Err(err) => return Err(err.into()), }; uwu_progress_bar.update_progess(uwu_text.len()); @@ -84,20 +89,24 @@ impl UwUify { } } else { // Handle File I/O + if UwUOutFile::exists(&self.output) { + return Err(format!("File '{}' already exists, aborting operation", &self.output).into()); + }; + let mut uwu_in_file = match UwUInFile::new(&self.input) { Ok(uwu_in_file) => uwu_in_file, - Err(err) => return Err(err), + Err(err) => return Err(err.into()), }; let mut uwu_out_file = match UwUOutFile::new(&self.output) { Ok(uwu_out_file) => uwu_out_file, - Err(err) => return Err(err) + Err(err) => return Err(err.into()) }; let mut uwu_progress_bar = UwUProgressBar::new(uwu_in_file.get_file_bytes()); loop { let bytes_read_in = match uwu_in_file.read_until_newline() { Ok(bytes_read_in) => bytes_read_in, - Err(err) => return Err(err), + Err(err) => return Err(err.into()), }; if bytes_read_in == 0 { break; } @@ -105,7 +114,7 @@ impl UwUify { let uwu_sentence = self.uwuify_sentence(&utf8_str); match uwu_out_file.write_string_with_newline(&uwu_sentence) { Ok(_) => (), - Err(err) => return Err(err), + Err(err) => return Err(err.into()), }; uwu_progress_bar.update_progess(bytes_read_in); From 8c50ba27fbbce2dc341bdf46209f3667bdb60c14 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 28 Jan 2022 22:15:57 +0000 Subject: [PATCH 2/7] Update version to v0.1.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 199b3b5..38c7219 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uwuifyy" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Goudham "] description = "A robust, customizable, efficient and easy-to-use command line application to uwu'ify your text!" From 30a8c9333545c39bbb1b642c12bcd2a4443b1e2d Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 28 Jan 2022 23:40:28 +0000 Subject: [PATCH 3/7] Update README.md --- README.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5ab1986..061ad50 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,90 @@ allows you to _uwu'ify_ text and files from within your own terminal in an _extr ## Installation -**Binaries will be available soon™** +Binaries for **Windows**, **macOS** & **Linux** are available with every single [release](https://github.com/sgoudham/uwuifyy/releases) -If using Rust's package manager, `Cargo`, all that is needed is +### Windows -```commandline +1. Download either `uwuifyy-x86_64-pc-windows-msvc.zip` or `uwuifyy-x86_64-pc-windows-gnu.zip` + + +2. Extract into `\bin` folder at `C:\your\path\here\` + +``` +C: +|__your + |__path + |__here + |__bin + |__uwuifyy.exe +``` + +3. Set `uwuifyy.exe` in your path to access it globally + +```shell +setx path "%path%;C:\your\path\here\bin" +``` + +4. Refresh command line and verify installation + +```shell +uwuifyy --help +``` + +### Linux / macOS + +1. Download `uwuifyy-x86_64-unknown-linux-gnu.tar.gz` or `uwuifyy-x86_64-unknown-linux-musl.tar.gz` + or `uwuifyy-x86_64-apple-darwin.tar.gz` + + +2. Extract into your local directory + +```shell +# Linux +tar -xf uwuifyy-x86_64-unknown-linux-gnu.tar.gz +tar -xf uwuifyy-x86_64-unknown-linux-musl.tar.gz + +# macOS +tar -xf uwuifyy-x86_64-apple-darwin.tar.gz +``` + +3. Movie into `~/bin` + +```shell +# Create ~/bin if it does not exist +mkdir -p ~/bin +mv uwuifyy ~/bin +``` + +4. Set permissions for executable + +```shell +chmod 755 ~/bin/uwuifyy +``` + +5. Update `PATH` to use globally + +```shell +# Linux +echo 'export PATH=~/bin:$PATH' >> ~/.bashrc +source ~/.bashrc + +# macOS +echo 'export PATH=~/bin:$PATH' >> ~/.bash_profile +source ~/.bash_profile +``` + +6. Verify installation + +```shell +uwuifyy --help +``` + +### Rust/Cargo + +Alternatively, if using Rust's package manager, `Cargo`, all that is needed is + +```shell cargo install uwuifyy ``` @@ -57,7 +136,7 @@ Rust [here](https://www.rust-lang.org/tools/install) ## Usage -```commandline +```shell USAGE: uwuifyy.exe [OPTIONS] <--text |--infile > @@ -76,14 +155,14 @@ OPTIONS: ### Text Input to Text Output -```commandline +```shell C:\Your\Path\Here> uwuifyy --text "According to all known laws of aviation, there is no way a bee should be able to fly." > Accowding to aww knyown waws of aviation, thewe xDD is nyo way :3 a bee shouwd be abwe to *screams* fwy. ``` ### Text Input to File Output -```commandline +```shell C:\Your\Path\Here> uwuifyy --text "According to all known laws of aviation, there is no way a bee should be able to fly." --outfile your/path/here/outfile.txt [00:00:00] [############################################################] 104B/104B (0s) UwU'ifying Complete! ``` @@ -102,7 +181,7 @@ your/path/here/infile.txt According to all known laws of aviation, there is no way a bee should be able to fly. ``` -```commandline +```shell PS D:\Programming\Personal\uwuifyy> uwuifyy --infile your/path/here/infile.txt --outfile your/path/here/outfile.txt [00:00:00] [############################################################] 85B/85B (0s) UwU'ifying Complete! ``` From d4878cba8109b46c7461080a8dc40eec989e053a Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 28 Jan 2022 23:44:15 +0000 Subject: [PATCH 4/7] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 061ad50..e3f8e65 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ tar -xf uwuifyy-x86_64-unknown-linux-musl.tar.gz tar -xf uwuifyy-x86_64-apple-darwin.tar.gz ``` -3. Movie into `~/bin` +3. Move into `~/bin` ```shell # Create ~/bin if it does not exist From fba9d1639b3af00248db06a020c31a431e7b8200 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 28 Jan 2022 23:49:01 +0000 Subject: [PATCH 5/7] Reformat README.md --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e3f8e65..bdcd919 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ * [About](#about) * [Features](#features) * [Installation](#installation) + + [Windows](#windows) + + [Linux / macOS](#Linux-/-macOS) + + [Rust/Cargo](#Rust/Cargo) * [Usage](#usage) + [Text Input to Text Output](#text-input-to-text-output) + [Text Input to File Output](#text-input-to-file-output) @@ -44,7 +47,8 @@ allows you to _uwu'ify_ text and files from within your own terminal in an _extr ## Installation -Binaries for **Windows**, **macOS** & **Linux** are available with every single [release](https://github.com/sgoudham/uwuifyy/releases) +Binaries for **Windows**, **macOS** & **Linux** are available with every +single [release](https://github.com/sgoudham/uwuifyy/releases) ### Windows @@ -136,7 +140,7 @@ Rust [here](https://www.rust-lang.org/tools/install) ## Usage -```shell +```commandline USAGE: uwuifyy.exe [OPTIONS] <--text |--infile > @@ -156,14 +160,14 @@ OPTIONS: ### Text Input to Text Output ```shell -C:\Your\Path\Here> uwuifyy --text "According to all known laws of aviation, there is no way a bee should be able to fly." -> Accowding to aww knyown waws of aviation, thewe xDD is nyo way :3 a bee shouwd be abwe to *screams* fwy. +uwuifyy --text "According to all known laws of aviation, there is no way a bee should be able to fly." + Accowding to aww knyown waws of aviation, thewe xDD is nyo way :3 a bee shouwd be abwe to *screams* fwy. ``` ### Text Input to File Output ```shell -C:\Your\Path\Here> uwuifyy --text "According to all known laws of aviation, there is no way a bee should be able to fly." --outfile your/path/here/outfile.txt +uwuifyy --text "According to all known laws of aviation, there is no way a bee should be able to fly." --outfile your/path/here/outfile.txt [00:00:00] [############################################################] 104B/104B (0s) UwU'ifying Complete! ``` @@ -182,7 +186,7 @@ According to all known laws of aviation, there is no way a bee should be able to ``` ```shell -PS D:\Programming\Personal\uwuifyy> uwuifyy --infile your/path/here/infile.txt --outfile your/path/here/outfile.txt +uwuifyy --infile your/path/here/infile.txt --outfile your/path/here/outfile.txt [00:00:00] [############################################################] 85B/85B (0s) UwU'ifying Complete! ``` From 1e250c9a00acecbc342ae9bebcb39d2a58d37017 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 28 Jan 2022 23:52:33 +0000 Subject: [PATCH 6/7] Reformat README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bdcd919..1732788 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ According to all known laws of aviation, there is no way a bee should be able to ``` ```shell -uwuifyy --infile your/path/here/infile.txt --outfile your/path/here/outfile.txt +uwuifyy --infile your/path/here/infile.txt --outfile your/path/here/outfile.txt [00:00:00] [############################################################] 85B/85B (0s) UwU'ifying Complete! ``` From 78f8bdc09f96ba0508196067939b577c47bedbca Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 28 Jan 2022 23:54:16 +0000 Subject: [PATCH 7/7] Reformat README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1732788..6be3a8a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ * [Installation](#installation) + [Windows](#windows) + [Linux / macOS](#Linux-/-macOS) - + [Rust/Cargo](#Rust/Cargo) + + [Rust/Cargo](#Rust-/-Cargo) * [Usage](#usage) + [Text Input to Text Output](#text-input-to-text-output) + [Text Input to File Output](#text-input-to-file-output) @@ -127,7 +127,7 @@ source ~/.bash_profile uwuifyy --help ``` -### Rust/Cargo +### Rust / Cargo Alternatively, if using Rust's package manager, `Cargo`, all that is needed is