aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-05-18 15:46:38 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-18 15:46:38 +0800
commitf1408931eb19f90dd96092ea26bea8d14f5ec804 (patch)
tree19daeb4df4742c91e83b843a83dea54e7170f7f1
parent8840529533a6bb49439a1f7eb9f93c117f20b9f7 (diff)
Move hook execution into the async and sync run methods
-rw-r--r--mingling_core/src/program.rs6
-rw-r--r--mingling_core/src/program/exec.rs2
2 files changed, 6 insertions, 2 deletions
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs
index fbffb3d..7c667e4 100644
--- a/mingling_core/src/program.rs
+++ b/mingling_core/src/program.rs
@@ -220,6 +220,9 @@ where
where
C: 'static + Send + Sync,
{
+ // Run hooks
+ self.run_hook_on_begin();
+
self.args = self.args.iter().skip(1).cloned().collect();
match self
.exec_wrapper(|p| async { crate::exec::exec(p).await.map_err(|e| e.into()) })
@@ -331,6 +334,9 @@ where
where
C: 'static + Send + Sync,
{
+ // Run hooks
+ self.run_hook_on_begin();
+
self.args = self.args.iter().skip(1).cloned().collect();
match self.exec_wrapper(|p| crate::exec::exec(p).map_err(|e| e.into())) {
Ok(r) => r,
diff --git a/mingling_core/src/program/exec.rs b/mingling_core/src/program/exec.rs
index 969b64e..1b756a1 100644
--- a/mingling_core/src/program/exec.rs
+++ b/mingling_core/src/program/exec.rs
@@ -16,7 +16,6 @@ where
C: ProgramCollect<Enum = C>,
{
// Run hooks
- program.run_hook_on_begin();
program.run_hook_pre_dispatch(&program.args);
#[cfg(not(feature = "dispatch_tree"))]
@@ -108,7 +107,6 @@ where
C: ProgramCollect<Enum = C>,
{
// Run hooks
- program.run_hook_on_begin();
program.run_hook_pre_dispatch(&program.args);
#[cfg(not(feature = "dispatch_tree"))]