56 lines
1001 B
Rust
56 lines
1001 B
Rust
use std::fs::File;
|
|
use std::io;
|
|
use std::io::Read;
|
|
use std::env;
|
|
|
|
const EXEC: [(i32, (&'static str, i32)); 1] = [
|
|
(0, ("add", 0))
|
|
];
|
|
|
|
struct Exec {
|
|
arguments: i32,
|
|
name: String
|
|
}
|
|
|
|
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 parse(contents: String) -> Vec<Exec> {
|
|
return vec![];
|
|
}
|
|
|
|
fn exec(instructions: Vec<Exec>) {
|
|
}
|
|
|
|
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);
|
|
|
|
let contents = match contents {
|
|
Ok(v) => v,
|
|
Err(e) => {
|
|
println!("{}", e);
|
|
return;
|
|
}
|
|
};
|
|
|
|
let parsed = parse(contents);
|
|
|
|
let execd = exec(parsed);
|
|
}
|