Added text input and file reading
This commit is contained in:
parent
3d57d7df0d
commit
ff57a5dc6b
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
@ -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"
|
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "TextAdventureEngine"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
20
src/main.rs
Normal file
20
src/main.rs
Normal file
|
@ -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(())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user