diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-12 19:04:12 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-12 19:04:12 +0800 |
| commit | 72c57380883a1c1cc796dea6d35048ab5bed5f53 (patch) | |
| tree | 936e04d2ec0f5bae54667beac6bf069208900a80 /src/cmds/cmd/helpdoc.rs | |
| parent | 9d812580557cdc343378816cd65678b8aa75d944 (diff) | |
Add helpdoc system with interactive viewer
Diffstat (limited to 'src/cmds/cmd/helpdoc.rs')
| -rw-r--r-- | src/cmds/cmd/helpdoc.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cmds/cmd/helpdoc.rs b/src/cmds/cmd/helpdoc.rs new file mode 100644 index 0000000..8b692ee --- /dev/null +++ b/src/cmds/cmd/helpdoc.rs @@ -0,0 +1,49 @@ +use crate::{ + cmd_output, + cmds::{ + arg::helpdoc::JVHelpdocArgument, collect::empty::JVEmptyCollect, + r#in::helpdoc::JVHelpdocInput, out::none::JVNoneOutput, + }, + systems::{ + cmd::{ + cmd_system::JVCommandContext, + errors::{CmdExecuteError, CmdPrepareError}, + }, + helpdoc::helpdoc_viewer, + }, +}; +use cmd_system_macros::exec; +use std::any::TypeId; + +pub struct JVHelpdocCommand; +type Cmd = JVHelpdocCommand; +type Arg = JVHelpdocArgument; +type In = JVHelpdocInput; +type Collect = JVEmptyCollect; + +async fn help_str() -> String { + helpdoc_viewer::display("Welcome_To_JVCS").await; + String::new() +} + +async fn prepare(args: &Arg, ctx: &JVCommandContext) -> Result<In, CmdPrepareError> { + Ok(JVHelpdocInput { + name: args.doc_name.clone(), + lang: ctx.lang.clone(), + }) +} + +async fn collect(_args: &Arg, _ctx: &JVCommandContext) -> Result<Collect, CmdPrepareError> { + Ok(JVEmptyCollect) +} + +#[exec] +async fn exec( + input: In, + _collect: Collect, +) -> Result<(Box<dyn std::any::Any + Send + 'static>, TypeId), CmdExecuteError> { + helpdoc_viewer::display_with_lang(&input.name.as_str(), &input.lang.as_str()).await; + cmd_output!(JVNoneOutput => JVNoneOutput) +} + +crate::command_template!(); |
