A sheep speaks.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

rename --tip to --muse and update accordingly

Kevin 7f3869d7 aac9bc7e

+10 -10
+10 -10
src/main.rs
··· 13 13 const MAX_BUBBLE_SIZE: usize = 60; 14 14 const MIN_CLONE_INNER: usize = 22; 15 15 16 - const TIPS: &[&str] = &[ 16 + const MUSINGS: &[&str] = &[ 17 17 "I push, therefore I baa.", 18 18 "Identity portable. Repos plural. Wool eternal.", 19 19 ]; ··· 33 33 #[arg(long)] 34 34 clone: bool, 35 35 36 - /// Have Dolly share a random Tangled tip. 36 + /// Have Dolly share what's on her mind. 37 37 #[arg(long)] 38 - tip: bool, 38 + muse: bool, 39 39 } 40 40 41 41 fn main() -> ExitCode { ··· 74 74 // Finds where the message text comes from: positional args or piped stdin, 75 75 // or falls back to default string. 76 76 fn resolve_message(cli: &Cli) -> io::Result<String> { 77 - // --tip wins over positional/stdin: the user is explicitly asking for one. 78 - if cli.tip { 79 - return Ok(random_tip().to_string()); 77 + // --muse wins over positional/stdin: the user is explicitly asking for one. 78 + if cli.muse { 79 + return Ok(random_musing().to_string()); 80 80 } 81 81 82 82 // positional args ··· 100 100 Ok(buf.trim_end().to_string()) 101 101 } 102 102 103 - // Picks a tip pseudo-randomly. Uses the system clock as the seed source so we 103 + // Picks a musing pseudo-randomly. Uses the system clock as the seed source so we 104 104 // don't pull in `rand`. 105 - fn random_tip() -> &'static str { 106 - if TIPS.is_empty() { 105 + fn random_musing() -> &'static str { 106 + if MUSINGS.is_empty() { 107 107 return "Baa!"; 108 108 } 109 109 let nanos = SystemTime::now() 110 110 .duration_since(UNIX_EPOCH) 111 111 .map(|d| d.as_millis()) 112 112 .unwrap_or(0); 113 - TIPS[(nanos as usize) % TIPS.len()] 113 + MUSINGS[(nanos as usize) % MUSINGS.len()] 114 114 } 115 115 116 116 // Computes the wrap width for the message inside the bubble.