diff options
Diffstat (limited to 'mingling_core/src/program')
| -rw-r--r-- | mingling_core/src/program/exec.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mingling_core/src/program/exec.rs b/mingling_core/src/program/exec.rs index c1eada5..469f6d2 100644 --- a/mingling_core/src/program/exec.rs +++ b/mingling_core/src/program/exec.rs @@ -16,6 +16,11 @@ where let mut current = dispatch_args_dynamic(program, program.args.clone())?; let mut stop_next = false; + // If the program has Help enabled, skip actual logic and jump to Help + if program.user_context.help { + return Ok(render_help::<C>(program, current)); + } + loop { let final_exec = stop_next; @@ -56,6 +61,11 @@ where let mut current = dispatch_args_dynamic(program, program.args.clone())?; let mut stop_next = false; + // If the program has Help enabled, skip actual logic and jump to Help + if program.user_context.help { + return Ok(render_help::<C>(program, current)); + } + loop { let final_exec = stop_next; @@ -179,3 +189,28 @@ fn render<C: ProgramCollect<Enum = C>>(program: &Program<C>, any: AnyOutput<C>) } } } + +#[inline(always)] +#[allow(unused_variables)] +fn render_help<C: ProgramCollect<Enum = C>>( + program: &Program<C>, + entry: AnyOutput<C>, +) -> RenderResult { + #[cfg(not(feature = "general_renderer"))] + { + let mut render_result = RenderResult::default(); + C::render_help(entry, &mut render_result); + render_result + } + #[cfg(feature = "general_renderer")] + { + match program.general_renderer_name { + super::GeneralRendererSetting::Disable => { + let mut render_result = RenderResult::default(); + C::render_help(entry, &mut render_result); + render_result + } + _ => RenderResult::default(), + } + } +} |
