This commit is contained in:
2017-05-23 20:01:18 -04:00
commit 6f1f3b8a94
4 changed files with 43 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target

4
Cargo.lock generated Normal file
View File

@@ -0,0 +1,4 @@
[root]
name = "vvm"
version = "0.1.0"

6
Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "vvm"
version = "0.1.0"
authors = ["hellerve <veit@veitheller.de>"]
[dependencies]

32
src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
use std::fs::File;
use std::io;
use std::io::Read;
use std::env;
fn usage(pname: String) {
println!("usage: {} <file>", pname);
}
fn get_contents(fname: String) -> Result<String, io::Error> {
let mut file = try!(File::open(&*fname));
let mut contents = String::new();
try!(file.read_to_string(&mut contents));
Ok(contents)
}
fn main() {
let args: Vec<_> = env::args().collect();
if args.len() != 2 {
usage(args[0].clone());
return;
}
let fname = args[1].clone();
let contents = get_contents(fname);
match contents {
Ok(v) => println!("{}", v),
Err(e) => println!("{}", e)
}
}