Added arguments and modified .gitignore
I added -h / --help and -f / --file so that the wyst code files aren't hard coded This makes it easier to test and debug
This commit is contained in:
+14
-4
@@ -2,11 +2,21 @@ mod transpiler;
|
||||
mod parser;
|
||||
mod lexer;
|
||||
use std::fs;
|
||||
use clap::Parser;
|
||||
|
||||
|
||||
//Arguments for Wyst (short and long version)
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
#[clap(short, long)]
|
||||
file: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let code_file = "code.wst";
|
||||
let contents = fs::read_to_string(code_file).expect("cannot read for some reason");
|
||||
let result = transpiler::transpile(contents, 0);
|
||||
println!("{result}")
|
||||
let args = Args::parse();
|
||||
let file_content = fs::read_to_string(&args.file)
|
||||
.expect("Error reading file");
|
||||
|
||||
let transpiled_code = transpiler::transpile(file_content, 0);
|
||||
println!("{}", transpiled_code);
|
||||
}
|
||||
Reference in New Issue
Block a user