use std::io::Write;
use std::process::Command;

const FORTUNE: &str = "fortune";

fn main() {
    println!("[FORTUNE COOKIE]");
    println!("{}", fortune());
}

/// Get a fortune cookie.
fn fortune() -> String {
    let output = Command::new(FORTUNE)
        .arg("-s")  // Short fortunes only
        .output()
        .expect("Failed to get fortune");

        String::from_utf8(output.stdout).expect("Failed to decode output")
}

fn main() {
    println!("Hello, world!");
}

--- 
+++ 
@@ -1,3 +1,19 @@
+use std::io::Write;
+use std::process::Command;
+
+const FORTUNE: &str = "fortune";
+
 fn main() {
-    println!("Hello, world!");
+    println!("[FORTUNE COOKIE]");
+    println!("{}", fortune());
 }
+
+/// Get a fortune cookie.
+fn fortune() -> String {
+    let output = Command::new(FORTUNE)
+        .arg("-s")  // Short fortunes only
+        .output()
+        .expect("Failed to get fortune");
+
+        String::from_utf8(output.stdout).expect("Failed to decode output")
+}
Print fortune using fortune command
