From eeda98e41cc6e101528b2e16ef97017f786f2d87 Mon Sep 17 00:00:00 2001 From: teesh3rt Date: Mon, 24 Mar 2025 14:57:15 +0200 Subject: [PATCH] refact: dabble in macros a bit --- coreutils/src/commands/mod.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/coreutils/src/commands/mod.rs b/coreutils/src/commands/mod.rs index d1967a4..10521c0 100644 --- a/coreutils/src/commands/mod.rs +++ b/coreutils/src/commands/mod.rs @@ -1,17 +1,13 @@ -mod hello; -pub use hello::Hello; +macro_rules! command { + ($mod:ident::$cmd:ident) => { + mod $mod; + pub use $mod::$cmd; + }; +} -mod cat; -pub use cat::Cat; - -mod echo; -pub use echo::Echo; - -mod mkdir; -pub use mkdir::Mkdir; - -mod dd; -pub use dd::Dd; - -mod nproc; -pub use nproc::Nproc; +command!(hello::Hello); +command!(cat::Cat); +command!(echo::Echo); +command!(mkdir::Mkdir); +command!(dd::Dd); +command!(nproc::Nproc);