initial
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
target
|
4
Cargo.lock
generated
Normal file
4
Cargo.lock
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[root]
|
||||||
|
name = "vvm"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "vvm"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["hellerve <veit@veitheller.de>"]
|
||||||
|
|
||||||
|
[dependencies]
|
32
src/main.rs
Normal file
32
src/main.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user