diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..0dce66a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "TextAdventureEngine" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..497e633 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "TextAdventureEngine" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d81bcab --- /dev/null +++ b/src/main.rs @@ -0,0 +1,20 @@ +use std::io; +use std::io::BufRead; +use std::io::Read; +use std::io::Error; +use std::fs::File; + +fn main() -> std::io::Result<()> { + println!("Please enter the path to the config file. "); + let mut s=String::new(); + let stdin = io::stdin(); + let mut handle = stdin.lock(); + handle.read_line(&mut s).unwrap(); + let s: String = s.trim().parse().unwrap(); + println!("You typed: {}",s); + let mut read = File::open(s)?; + let mut contents = String::new(); + read.read_to_string(&mut contents)?; + println!("{}",contents); + Ok(()) +} diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..c4fc94e --- /dev/null +++ b/test.txt @@ -0,0 +1,3 @@ +hello +my name +is Ethan