main
Jordan Orelli 9 months ago
parent af181b372c
commit b48e0b65d0

@ -14,6 +14,8 @@ mod pwd;
/// removes files
mod rm;
mod mkdir;
/// the butt of a file
mod tail;
@ -32,6 +34,7 @@ pub enum Builtin {
Changedir,
Echo,
Ls,
Mkdir,
Printenv,
Pwd,
Rm,
@ -46,6 +49,7 @@ impl Builtin {
Changedir => &cd::Changedir,
Echo => &echo::Echo,
Ls => &ls::Ls,
Mkdir => &mkdir::Mkdir,
Printenv => &printenv::Printenv,
Pwd => &pwd::Pwd,
Rm => &rm::Rm,
@ -68,6 +72,7 @@ pub fn all() -> HashMap<&'static str, Builtin> {
("cd", Changedir),
("echo", Echo),
("ls", Ls),
("mkdir", Mkdir),
("printenv", Printenv),
("pwd", Pwd),
("rm", Rm),

@ -0,0 +1,25 @@
use crate::{
error::ExecError,
run::{Call, Context, Value},
};
use std::{env, fs, io::Write};
pub struct Mkdir;
impl Call for Mkdir {
fn call(&self, ctx: &mut Context, args: &[Value]) -> Result<Value, ExecError> {
match args.len() {
0 => {
todo!()
}
1 => {
let path = args[0].try_as_str()?;
fs::create_dir(path)?;
}
_ => {
todo!()
}
}
Ok(Value::None)
}
}
Loading…
Cancel
Save