Skip to content

Help command and --help flag should render markdown#6

Merged
tig merged 3 commits into
mainfrom
tig/fix-help-markdown-rendering
May 24, 2026
Merged

Help command and --help flag should render markdown#6
tig merged 3 commits into
mainfrom
tig/fix-help-markdown-rendering

Conversation

@tig
Copy link
Copy Markdown
Member

@tig tig commented May 24, 2026

Fixes #5

Problem

  1. example-app help launches TUI but HelpCommand.RunAsync just returns markdown as a CommandResult — doesn't display it in a Terminal.Gui Markdown viewer.
  2. example-app --help writes plain text directly via stdout.WriteLine without ANSI markdown rendering.
  3. MetadataHelpProvider.GetRootHelp generates plain text, not markdown.

Plan

1. Convert MetadataHelpProvider.GetRootHelp to generate markdown

Use ## headings, bullet lists for commands, and backtick formatting for options — so both help and --help paths start from the same markdown source.

2. Fix CliHost.WriteRootFlag to render via MarkdownRenderer.RenderToAnsi

Pass the markdown through MarkdownRenderer.RenderToAnsi instead of writing it directly with stdout.WriteLine.

3. Fix HelpCommand.RunAsync to launch TUI markdown viewer

Use RunnableWrapper<Markdown, object?> to display the help content in a fullscreen Terminal.Gui Markdown view, following the same pattern as InputCommandRunner.

RenderCatAsync already correctly uses MarkdownRenderer.RenderToAnsi — no change needed there.

4. Add tests

  • --help produces ANSI-rendered output
  • MetadataHelpProvider generates markdown
  • help --cat still works correctly

Notes

  • No public API signature changes — behavioral change only
  • Both paths (help command and --help flag) will share the same markdown source

tig and others added 3 commits May 24, 2026 09:04
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Convert MetadataHelpProvider.GetRootHelp to generate markdown with
  ## headings, bullet lists, and backtick formatting
- Fix CliHost.WriteRootFlag to render via MarkdownRenderer.RenderToAnsi
  instead of plain stdout.WriteLine
- Fix HelpCommand.RunAsync to display markdown in a fullscreen
  Terminal.Gui Markdown viewer using RunnableWrapper
- Add tests for --help ANSI output, help --cat, and MetadataHelpProvider
  markdown generation

Fixes #5

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…on tests

The help command's TUI viewer rendered empty content because
Markdown.Text was set before the view was initialized/laid out.
Following the pattern from gui-cs/clet's MarkdownClet, set the text
inside the Initialized event handler on the containing Runnable.

Also switches from RunnableWrapper to a plain Runnable with an embedded
Markdown view — the help viewer is read-only and needs no result
extraction.

Adds integration tests using Application.Create()/Init(ansi) with
StopAfterFirstIteration to verify:
- The TUI renders without hanging
- Driver contents contain expected command text
- Subcommand help renders correctly
- RenderCatAsync produces ANSI output

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tig tig marked this pull request as ready for review May 24, 2026 19:14
@tig tig merged commit b4af0ca into main May 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant