perspt_core/
local_command.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum LocalCommand {
6 Love,
8}
9
10pub const DEDICATION_TITLE: &str = "Special Dedication";
11pub const DEDICATION_PREAMBLE: &str = "This application is lovingly dedicated to";
12pub const DEDICATION_FAMILY: &str =
13 "my wonderful mothers DaiJun(黛君), VijayLaxmi and grandma Sushila";
14pub const DEDICATION_THANKS: &str = "Thank you for your endless love, wisdom, and support";
15pub const DEDICATION_CLOSING: &str = "With all my love and gratitude";
16
17pub fn parse_local_command(input: &str) -> Option<LocalCommand> {
19 input
20 .trim()
21 .eq_ignore_ascii_case("l-o-v-e")
22 .then_some(LocalCommand::Love)
23}
24
25pub fn dedication_text() -> String {
27 format!(
28 "{DEDICATION_TITLE}\n\n{DEDICATION_PREAMBLE}\n {DEDICATION_FAMILY}\n\n\
29 {DEDICATION_THANKS}\n\n{DEDICATION_CLOSING}"
30 )
31}
32
33#[cfg(test)]
34mod tests {
35 use super::*;
36
37 #[test]
38 fn love_is_case_insensitive_and_exact() {
39 assert_eq!(parse_local_command("l-o-v-e"), Some(LocalCommand::Love));
40 assert_eq!(parse_local_command(" L-O-V-E "), Some(LocalCommand::Love));
41 assert_eq!(parse_local_command("love"), None);
42 assert_eq!(parse_local_command("l-o-v-e now"), None);
43 }
44
45 #[test]
46 fn dedication_names_the_family() {
47 let text = dedication_text();
48 assert!(text.contains("DaiJun(黛君), VijayLaxmi and grandma Sushila"));
49 }
50}