Make pwd accessible
This commit is contained in:
parent
30e528631a
commit
fa9ee5f864
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -127,7 +127,7 @@ checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-terminal"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"wasm-bindgen",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasm-terminal"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
authors = ["Daniel Kluge <daniel-git@c0ntroller.de>"]
|
||||
description = "Console application with commands in WASM for my website"
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -185,7 +185,8 @@ impl Console {
|
||||
#[wasm_bindgen]
|
||||
impl Console {
|
||||
pub fn new() -> Console {
|
||||
// TODO remove in release
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
let root = Rc::new(RefCell::new(Directory::new("".to_string(), "".to_string())));
|
||||
@ -205,6 +206,13 @@ impl Console {
|
||||
self.output.clone()
|
||||
}
|
||||
|
||||
pub fn get_pwd(&self) -> String {
|
||||
match self.pwd.borrow().last() {
|
||||
Some(dir) => dir.borrow().get_path(),
|
||||
None => "/".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_last_commands(&self) -> Vec<String> {
|
||||
self.last_commands.clone()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user