List of paths
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
#![feature(box_patterns, box_syntax, proc_macro_hygiene, decl_macro)]
|
||||
#![feature(plugin)]
|
||||
extern crate colored;
|
||||
extern crate itertools;
|
||||
extern crate linefeed;
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
@@ -13,7 +10,7 @@ extern crate serde_json;
|
||||
use std::collections::HashSet;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
|
||||
mod language;
|
||||
@@ -32,16 +29,18 @@ pub fn start_repl(langs: Vec<Box<dyn ProgrammingLanguageInterface>>) {
|
||||
repl.run_repl();
|
||||
}
|
||||
|
||||
//TODO should really expect a list of paths
|
||||
pub fn run_noninteractive(filename: &str, languages: Vec<Box<dyn ProgrammingLanguageInterface>>) {
|
||||
let path = Path::new(filename);
|
||||
let ext = path
|
||||
pub fn run_noninteractive(filenames: Vec<PathBuf>, languages: Vec<Box<dyn ProgrammingLanguageInterface>>) {
|
||||
// for now, ony do something with the first filename
|
||||
|
||||
let filename = &filenames[0];
|
||||
let ext = filename
|
||||
.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
.unwrap_or_else(|| {
|
||||
println!("Source file lacks extension");
|
||||
println!("Source file `{}` has no extension.", filename.display());
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let mut language = Box::new(
|
||||
languages
|
||||
.into_iter()
|
||||
@@ -52,7 +51,7 @@ pub fn run_noninteractive(filename: &str, languages: Vec<Box<dyn ProgrammingLang
|
||||
}),
|
||||
);
|
||||
|
||||
let mut source_file = File::open(path).unwrap();
|
||||
let mut source_file = File::open(filename).unwrap();
|
||||
let mut buffer = String::new();
|
||||
source_file.read_to_string(&mut buffer).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user