use std::env;
use std::fs::File;
use std::io::Error;
use std::io::prelude::*;

fn read_file(filename: &str) -> Result<String, Error> {
    let mut file = File::open(filename)?;
    let mut contents = String::new();
    let _ = file.read_to_string(&mut contents)?;
    Ok(contents)
}

fn main()  -> Result<(), Error> {
    let args: Vec<String> = env::args().collect();
    if args.len() < 2 {
        eprintln!("ファイル名を指定してください。");
        return Ok(());
    }
    let filename = &args[1];
    let s = read_file(filename)?;
    println!("{s}");
    Ok(())
}
