diff --git a/src/entrypoint.rs b/src/entrypoint.rs index a182bd9..223c00b 100644 --- a/src/entrypoint.rs +++ b/src/entrypoint.rs @@ -3,7 +3,7 @@ use clap::{App, Arg}; pub fn main() { let matches = App::new("Emojifier") .version("1.0") - .author("Daniel T. ") .about("Applies Emoji effects to text") .arg( Arg::new("input") @@ -13,8 +13,18 @@ pub fn main() { ) .arg( Arg::new("hands") + .short('H') .long("hands") + .takes_value(false) .about("TURNS 👏 YOUR 👏 TEXT 👏 INTO 👏 THIS"), ) .get_matches(); + + if let Some(input) = matches.value_of("input") { + println!("{}", crate::hands::handify(input)); + } + + if matches.is_present("hands") { + println!("{}", true) + } } diff --git a/src/hands.rs b/src/hands.rs new file mode 100644 index 0000000..01d776a --- /dev/null +++ b/src/hands.rs @@ -0,0 +1,22 @@ +pub fn handify(input: &str) -> String { + let input = input.to_uppercase(); + let input = input.replace(" ", " 👏 "); + println!("{:?}", input.split_whitespace().collect::>()); + input +} + +#[test] +fn handify_test_no_trailing_spaces() { + let input = "hello world"; + assert_eq!(handify(input), "HELLO 👏 WORLD"); +} + +#[test] +// NOTE: Failing because of trailing whitespace +fn handify_test_with_trailing_spaces() { + let input = " hello world "; + assert_eq!(handify(input), "👏 HELLO 👏 WORLD 👏") +} + +// TODO: trim leading + tailing white space +// TODO: handle an empty string diff --git a/src/lib.rs b/src/lib.rs index 9b11663..9727e24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,2 @@ -pub mod entrypoint; \ No newline at end of file +pub mod entrypoint; +pub mod hands;