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::{DEFAULT_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(DEFAULT_HELPDOC).await; String::new() } async fn prepare(args: &Arg, ctx: &JVCommandContext) -> Result { Ok(JVHelpdocInput { name: args.doc_name.clone().unwrap_or(DEFAULT_HELPDOC.to_string()), lang: ctx.lang.clone(), }) } async fn collect(_args: &Arg, _ctx: &JVCommandContext) -> Result { Ok(JVEmptyCollect) } #[exec] async fn exec( input: In, _collect: Collect, ) -> Result<(Box, TypeId), CmdExecuteError> { helpdoc_viewer::display_with_lang(&input.name.as_str(), &input.lang.as_str()).await; cmd_output!(JVNoneOutput => JVNoneOutput) } crate::command_template!();