Created
October 24, 2018 23:13
-
-
Save richo/7454ae24987967e3cda00930cc6bc16f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
use std::io::{self, Write}; | |
use std::process; | |
fn embiggen_word(word: String) -> String { | |
word.chars().map(|c| { | |
match c { | |
'!' => ":exclamation:".to_string(), | |
'?' => ":question:".to_string(), | |
'0' => ":zero:".to_string(), | |
'1' => ":one:".to_string(), | |
'2' => ":two:".to_string(), | |
'3' => ":three:".to_string(), | |
'4' => ":four:".to_string(), | |
'5' => ":five:".to_string(), | |
'6' => ":six:".to_string(), | |
'7' => ":seven:".to_string(), | |
'8' => ":eight:".to_string(), | |
'9' => ":nine:".to_string(), | |
'™' => ":tm:".to_string(), | |
s => { | |
format!(":big-{}:", s) | |
}, | |
} | |
}).collect() | |
} | |
fn run() -> Result<(), std::io::Error> { | |
let mut stdout = io::stdout(); | |
let mut map = env::args().skip(1).map(embiggen_word); | |
stdout.write(b":sparkles:")?; | |
if let Some(i) = map.next() { | |
stdout.write(i.as_bytes())?; | |
for i in map { | |
stdout.write(b" ")?; | |
stdout.write(i.as_bytes())?; | |
} | |
} | |
stdout.write(b":end_sparkles:")?; | |
Ok(()) | |
} | |
fn main() { | |
if let Err(e) = run() { | |
eprintln!("Ohno: {:?}", e); | |
process::exit(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment