feat: add the pwd command

This commit is contained in:
Teesh 2025-03-24 20:22:33 +02:00
parent be4cbd760b
commit 826a914c8f
3 changed files with 20 additions and 0 deletions

View file

@ -15,3 +15,4 @@ command!(r#true::True);
command!(r#false::False);
command!(test::Test);
command!(yes::Yes);
command!(pwd::Pwd);

View file

@ -0,0 +1,18 @@
use boxutils::args::ArgParser;
use boxutils::commands::Command;
pub struct Pwd;
impl Command for Pwd {
fn execute(&self) {
let args = ArgParser::builder().add_flag("--help").parse_args("yes");
if args.get_flag("--help") {
println!("Usage: pwd");
return;
}
let pwd = std::env::current_dir().unwrap();
println!("{}", pwd.display());
}
}

View file

@ -19,6 +19,7 @@ pub fn get_registry() -> CommandRegistry {
);
registry.register("[", Box::new(coreutils::commands::Test::with_bracket()));
registry.register("yes", Box::new(coreutils::commands::Yes));
registry.register("pwd", Box::new(coreutils::commands::Pwd));
registry.register("box", Box::new(Boxcmd));
registry