Skip to main content

view_file/
view_file.rs

1use std::{env, fs};
2
3use txtview::TxtView;
4
5fn main() -> std::io::Result<()> {
6    let path = env::args()
7        .nth(1)
8        .ok_or_else(|| std::io::Error::other("usage: view_file <path>"))?;
9    let text =
10        fs::read_to_string(&path).map_err(|e| std::io::Error::other(format!("{}: {}", path, e)))?;
11
12    let mut viewer = TxtView::new(text);
13    viewer.run()
14}