Skip to content

Commit

Permalink
Merge pull request #1 from sgoudham/v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham authored Jan 29, 2022
2 parents 211b1f4 + 78f8bdc commit d9265dc
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uwuifyy"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Goudham <[email protected]>"]
description = "A robust, customizable, efficient and easy-to-use command line application to uwu'ify your text!"
Expand Down
103 changes: 93 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -44,11 +47,91 @@ 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. Move 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
```

Expand Down Expand Up @@ -76,15 +159,15 @@ OPTIONS:

### Text Input to Text Output

```commandline
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.
```shell
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
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
```shell
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!
```
Expand All @@ -102,8 +185,8 @@ your/path/here/infile.txt
According to all known laws of aviation, there is no way a bee should be able to fly.
```
```commandline
PS D:\Programming\Personal\uwuifyy> uwuifyy --infile your/path/here/infile.txt --outfile your/path/here/outfile.txt
```shell
uwuifyy --infile your/path/here/infile.txt --outfile your/path/here/outfile.txt
[00:00:00] [############################################################] 85B/85B (0s) UwU'ifying Complete!
```
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ struct Args {
text: Option<String>,

/// 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<std::path::PathBuf>,

/// 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<String>,

/// The modifier to determine how many words to be uwu'ified
Expand Down
25 changes: 17 additions & 8 deletions src/uwuify.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io::Error;
use std::error::Error;
use std::path::PathBuf;
use linkify::{LinkFinder, LinkKind};

Expand Down Expand Up @@ -59,22 +59,27 @@ impl UwUify {
}
}

pub fn uwuify(&self) -> Result<(), Error> {
pub fn uwuify(&self) -> Result<(), Box<dyn Error>> {
// 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());
Expand All @@ -84,28 +89,32 @@ 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; }

let utf8_str = uwu_in_file.get_buffer_as_utf8_str();
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);
Expand Down

0 comments on commit d9265dc

Please sign in to comment.