From c678582917c68cad3fb6ac6e079d93c5ca945ab0 Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Mon, 20 Nov 2023 01:57:41 -0500 Subject: [PATCH] feat: add support for custom before/after help --- src/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index dd3d152..3e7464c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -237,9 +237,11 @@ fn build_command_markdown( writeln!(buffer, "{}\n", about)?; } - // TODO(feature): Support printing custom before and after help texts. - assert!(command.get_before_help().is_none()); - assert!(command.get_after_help().is_none()); + if let Some(help) = command.get_before_long_help() { + writeln!(buffer, "{}\n", help)?; + } else if let Some(help) = command.get_before_help() { + writeln!(buffer, "{}\n", help)?; + } writeln!( buffer, @@ -258,6 +260,12 @@ fn build_command_markdown( .replace("Usage: ", "") )?; + if let Some(help) = command.get_after_long_help() { + writeln!(buffer, "{}\n", help)?; + } else if let Some(help) = command.get_after_help() { + writeln!(buffer, "{}\n", help)?; + } + //---------------------------------- // Subcommands //----------------------------------