diff --git a/Cargo.lock b/Cargo.lock index bb098bf..3979d85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "fumosay" -version = "0.1.0" +version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 459885a..0ccf15f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fumosay" -version = "0.1.0" +version = "0.1.1" edition = "2018" authors = ["Unbewohnte | Nikolay Kasyanov "] description = "Like cowsay, but with soft friends" diff --git a/README.md b/README.md index 334382a..bc1a70e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ # fumosay ## Like cowsay, but with soft friends (ᗜˬᗜ) + +--- + +## Compile +install Rust +- [installation instructions](https://www.rust-lang.org/tools/install) + +clone this repository +- `git clone https://github.com/Unbewohnte/fumosay` + +cd into cloned repo +- `cd fumosay/` + +compile for your OS && Architecture +- `cargo build --release` + + +**or** + +## Download a pre-compiled version +- [Download a version of your choice](https://github.com/Unbewohnte/fumosay/releases) + +--- + +## Use +``` +./fumosay [message] +``` + +--- + +## TODO list + +- ❌ Add more fumos +- ❌ Make it available to use other fumos +- ❌ Improve message {box|bubble} +- ❌ Create a {deb|rpm} package +- ❌ Make an `install.sh` script diff --git a/src/fumo.rs b/src/fumo.rs deleted file mode 100644 index 3bba2e9..0000000 --- a/src/fumo.rs +++ /dev/null @@ -1,14 +0,0 @@ -/// Indicator of where the message should be in fumofile -pub const MESSAGE_INDICATOR: &str = "!message"; -/// Fumofile name of the default fumo -pub const FUMO_DEFAULT: &str = "fumo.fumo"; - -/// Returns a resulting string with `MESSAGE_INDICATOR` replaced with given -/// `message`. If `MESSAGE_INDICATOR` is not present in fumofile - the -/// `message` will be added on the new line at the end of the fumofile. -pub fn sayify(fumofile_contents: &mut String, message: &str) -> String { - if fumofile_contents.contains(MESSAGE_INDICATOR) { - return fumofile_contents.replace(MESSAGE_INDICATOR,message); - } - return format!("{}\n{}", fumofile_contents, message); -} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 014816c..216fb0f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,22 @@ -mod fumo; - use std::path::Path; use std::fs; use std::env; +/// Indicator of where the message should be in fumofile +pub const MESSAGE_INDICATOR: &str = "!message"; +/// Fumofile name of the default fumo +pub const FUMO_DEFAULT: &str = "fumo.fumo"; + +/// Returns a resulting string with `MESSAGE_INDICATOR` replaced with given +/// `message`. If `MESSAGE_INDICATOR` is not present in fumofile - the +/// `message` will be added on the new line at the end of the fumofile. +fn process_message(fumofile_contents: &mut String, message: &str) -> String { + if fumofile_contents.contains(MESSAGE_INDICATOR) { + return fumofile_contents.replace(MESSAGE_INDICATOR,message); + } + return format!("{}\n{}", fumofile_contents, message); +} + fn main() { // get command line arguments let args: Vec = env::args().collect(); @@ -14,17 +27,17 @@ fn main() { std::process::exit(1); } - let clarg_message = &args[1..].join(" "); + let clarg_message: &String = &args[1..].join(" "); // path to the fumofile - let fumofile_default_path = format!("./fumofiles/{}",fumo::FUMO_DEFAULT); - let fumofile_path = Path::new(&fumofile_default_path); + let fumofile_default_path: String = format!("./fumofiles/{}",FUMO_DEFAULT); + let fumofile_path: &Path = Path::new(&fumofile_default_path); // read fumofile - let mut fumofile_contents = fs::read_to_string(fumofile_path).unwrap(); + let mut fumofile_contents: String = fs::read_to_string(fumofile_path).unwrap(); // parse the file and get the resulting string - let message: String = fumo::sayify(&mut fumofile_contents, clarg_message); + let message: String = process_message(&mut fumofile_contents, clarg_message); println!("{}", message); }