From c16858fd8d2a3eefbdd33d4f479bfebb2c82f3fc Mon Sep 17 00:00:00 2001 From: teesh3rt Date: Mon, 24 Mar 2025 15:00:14 +0200 Subject: [PATCH] feat: add true and false --- coreutils/src/commands/false.rs | 10 ++++++++++ coreutils/src/commands/mod.rs | 2 ++ coreutils/src/commands/true.rs | 10 ++++++++++ src/registry.rs | 2 ++ 4 files changed, 24 insertions(+) create mode 100644 coreutils/src/commands/false.rs create mode 100644 coreutils/src/commands/true.rs diff --git a/coreutils/src/commands/false.rs b/coreutils/src/commands/false.rs new file mode 100644 index 0000000..d162e34 --- /dev/null +++ b/coreutils/src/commands/false.rs @@ -0,0 +1,10 @@ +use boxutils::commands::Command; +use std::process::exit; + +pub struct False; + +impl Command for False { + fn execute(&self) { + exit(1); + } +} diff --git a/coreutils/src/commands/mod.rs b/coreutils/src/commands/mod.rs index 10521c0..f8e12de 100644 --- a/coreutils/src/commands/mod.rs +++ b/coreutils/src/commands/mod.rs @@ -11,3 +11,5 @@ command!(echo::Echo); command!(mkdir::Mkdir); command!(dd::Dd); command!(nproc::Nproc); +command!(r#true::True); +command!(r#false::False); diff --git a/coreutils/src/commands/true.rs b/coreutils/src/commands/true.rs new file mode 100644 index 0000000..3dcaf9c --- /dev/null +++ b/coreutils/src/commands/true.rs @@ -0,0 +1,10 @@ +use boxutils::commands::Command; +use std::process::exit; + +pub struct True; + +impl Command for True { + fn execute(&self) { + exit(0); + } +} diff --git a/src/registry.rs b/src/registry.rs index 8a18606..3133880 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -11,6 +11,8 @@ pub fn get_registry() -> CommandRegistry { registry.register("ash", Box::new(shell::ash::Ash)); registry.register("dd", Box::new(coreutils::commands::Dd)); registry.register("nproc", Box::new(coreutils::commands::Nproc)); + registry.register("true", Box::new(coreutils::commands::True)); + registry.register("false", Box::new(coreutils::commands::False)); registry.register("box", Box::new(Boxcmd)); registry