Skip to content

Commit

Permalink
feat: basic cli
Browse files Browse the repository at this point in the history
  • Loading branch information
viddrobnic committed Jun 2, 2024
1 parent 842f6ff commit 8f47248
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 1 deletion.
197 changes: 197 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
clap = { version = "4.5.4", features = ["derive"] }
parser = { path = "./parser" }
runtime = { path = "./runtime" }
25 changes: 24 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
use std::{fs, path::PathBuf};

use clap::Parser;

#[derive(Debug, Parser)]
#[command(version, about, long_about = None)]
struct Cli {
/// Path of the file to run
path: PathBuf,
}

fn main() {
println!("Hello, world!");
let cli = Cli::parse();
run(cli.path);
}

fn run(path: PathBuf) {
let input = match fs::read_to_string(path) {
Ok(input) => input,
Err(err) => panic!("Failed to read input file: {err}"),
};

// TODO: Better error handling
let program = parser::parse(&input).unwrap();
runtime::run(&program).unwrap();
}

0 comments on commit 8f47248

Please sign in to comment.