fn process_loadfile(arg: &str) -> Result<String, String> {
    if arg.is_empty() {
        return Err("Error: expected argument for command 'load'".to_string());
    }
    let path = Path::new(arg);
    let path_display = path.display();
    let mut file;
    match File::open(&path) {
        Err(why) => {
            return Err(format!(
                "Error: couldn't open {}: {}",
                path_display,
                why.description()
            ));
        }
        Ok(res) => {
            file = res;
        }
    }

    let mut contents = String::new();
    if let Err(why) = file.read_to_string(&mut contents) {
        return Err(format!(
            "Error: couldn't read {}: {}",
            path_display,
            why.description()
        ));
    }
    Ok(contents.trim().to_string())
}
Processes the LoadFile command.

The argument is a filename containing a Weld program. Returns the string
representation of the program or an error with an error message.
weld-repl/src/main.rs