Compare commits

...

1 Commits

Author SHA1 Message Date
fa9ee5f864 Make pwd accessible 2024-01-18 18:04:58 +01:00
3 changed files with 11 additions and 3 deletions

2
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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()
}