aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program/repl_exec.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-15 03:28:02 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-15 03:28:02 +0800
commitec6c87d12062576271231b88364a4aa00765ae65 (patch)
treec1fcc3583aaffa06c0857403b557231719dde1af /mingling_core/src/program/repl_exec.rs
parent372eb14ab9a9b7fc0e5334ca15a9d8b656140e54 (diff)
feat(core): allow pre_dispatch hooks to mutate arguments
Change `HookPreDispatchInfo.arguments` from `&[String]` to `&mut Vec<String>` so hooks can rewrite command-line arguments before dispatch.
Diffstat (limited to 'mingling_core/src/program/repl_exec.rs')
-rw-r--r--mingling_core/src/program/repl_exec.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/mingling_core/src/program/repl_exec.rs b/mingling_core/src/program/repl_exec.rs
index 9d9be30..b91f7bc 100644
--- a/mingling_core/src/program/repl_exec.rs
+++ b/mingling_core/src/program/repl_exec.rs
@@ -58,10 +58,10 @@ where
line: &mut readline,
});
- let args = split_input_string(&readline);
+ let mut args = split_input_string(&readline);
p.run_hook_repl_pre_exec(&crate::hook::HookREPLPreExecInfo { args: &args });
- match might_be_async::invoke!(exec_once(p, &args)) {
+ match might_be_async::invoke!(exec_once(p, &mut args)) {
Ok(r) => {
p.run_hook_repl_on_receive_result(&crate::hook::HookREPLOnReceiveResultInfo {
result: &r,
@@ -91,13 +91,13 @@ where
#[cfg(not(feature = "async"))]
fn exec_once<C>(
p: &'static Program<C>,
- args: &[String],
+ args: &mut Vec<String>,
) -> Result<RenderResult, ProgramInternalExecuteError>
where
C: ProgramCollect<Enum = C> + Send + Sync + 'static,
{
#[cfg(panic = "abort")]
- let exec_result = super::exec::exec_with_args(p, &args);
+ let exec_result = super::exec::exec_with_args(p, args);
#[cfg(not(panic = "abort"))]
let exec_result = {
@@ -130,7 +130,7 @@ where
#[cfg(feature = "async")]
async fn exec_once<C>(
p: &'static Program<C>,
- args: &[String],
+ args: &mut Vec<String>,
) -> Result<RenderResult, ProgramInternalExecuteError>
where
C: ProgramCollect<Enum = C> + Send + Sync + 'static,