From 0e250dd676c03590bc126df0b19c3d0c90550f7f Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Fri, 24 Jan 2020 11:27:46 +0100 Subject: [PATCH] basic project layout and the first version of main, which handles the commandline arguments but does not do anything real, before exiting --- .gitignore | 3 +++ Cargo.lock | 6 ++++++ Cargo.toml | 7 +++++++ src/main.rs | 26 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..632a353 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +*.iml +target/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..c2fa458 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "rust_lox" +version = "0.1.0" + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b71e144 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "rust_lox" +version = "0.1.0" +authors = ["Sander Hautvast "] +edition = "2018" + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..32e96c7 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,26 @@ +use std::process; +use std::env; + +/// main +/// no arguments: run interactively +/// 1 argument: run the script file specified +fn main() { + let args: Vec = env::args().collect(); + + match args.len() { + 1 => run_prompt(), + 2 => run_file(args.get(0).unwrap()), + _ => { + println!("Usage: lox: [script]"); + process::exit(64); + } + } +} + +fn run_file(_path: &String) { + +} + +fn run_prompt() { + +} \ No newline at end of file