diff --git a/Cargo.lock b/Cargo.lock index 17da18d..c269545 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "fumosay" -version = "0.4.2" +version = "0.4.3" dependencies = [ "clap", ] diff --git a/Cargo.toml b/Cargo.toml index cd5980f..755c957 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fumosay" -version = "0.4.2" +version = "0.4.3" edition = "2018" authors = ["Unbewohnte | Nikolay Kasyanov "] description = "Like cowsay, but with soft friends" diff --git a/src/main.rs b/src/main.rs index f30ec13..5cbaed3 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.4.2") + .version("0.4.3") .author("Unbewohnte | Nikolay Kasyanov ") .about("cowsay, but with soft friends") .arg( @@ -91,12 +91,19 @@ fn main() { fs::read_to_string(fumofile_path).expect("Could not find a fumofile!"); // process the message - let message_values = matches.values_of("message").expect("No message provided"); - let message_vec: Vec<&str> = message_values.collect(); - let joined_message = message_vec.join(" "); + let message = matches.values_of("message"); + match message { + Some(messages) => { + let message_vec: Vec<&str> = messages.collect(); + let joined_message = message_vec.join(" "); - // parse the file, insert fiven message and get the resulting string - let fumosay: String = process_message(&mut fumofile_contents, joined_message.as_str()); + // parse the file, insert fiven message and get the resulting string + let fumosay: String = process_message(&mut fumofile_contents, joined_message.as_str()); - println!("{}", fumosay); + println!("{}", fumosay); + } + None => { + print!("{}", matches.usage()) + } + } }