From 3724aaa9c40c9f7e9b67b3f1dee96a7b91fd2182 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Thu, 19 Aug 2021 13:23:06 +0300 Subject: [PATCH] Fixed multiple message args bug --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e4b118..a73aa26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "fumosay" -version = "0.3.0" +version = "0.3.1" dependencies = [ "clap", ] diff --git a/Cargo.toml b/Cargo.toml index 49b7ead..bd73e65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fumosay" -version = "0.3.0" +version = "0.3.1" edition = "2018" authors = ["Unbewohnte | Nikolay Kasyanov "] description = "Like cowsay, but with soft friends" diff --git a/src/main.rs b/src/main.rs index 79beaf8..d7a68ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ fn process_message(fumofile_contents: &mut String, message: &str) -> String { fn main() { // get command line arguments let matches = App::new("fumosay") - .version("0.3.0") + .version("0.3.1") .author("Unbewohnte | Nikolay Kasyanov ") .about("cowsay, but with soft friends") .arg( @@ -68,8 +68,13 @@ fn main() { // read fumofile let mut fumofile_contents: String = fs::read_to_string(fumofile_path).expect("Could not find a fumofile!"); + // process the message + let message_values = matches.values_of("message").unwrap(); + let message_vec: Vec<&str> = message_values.collect(); + let joined_message = message_vec.join(" "); + // parse the file and get the resulting string - let message: String = process_message(&mut fumofile_contents, matches.value_of("message").unwrap()); + let message: String = process_message(&mut fumofile_contents, joined_message.as_str()); println!("{}", message); }