Skip to content

Add HelpTopic inventory type for non-command help entries#1

Merged
gfnord merged 1 commit into
masterfrom
feat/help-topic-registry-local
Apr 18, 2026
Merged

Add HelpTopic inventory type for non-command help entries#1
gfnord merged 1 commit into
masterfrom
feat/help-topic-registry-local

Conversation

@gfnord

@gfnord gfnord commented Apr 18, 2026

Copy link
Copy Markdown
Owner

Local branch for testing the HelpTopic registry on top of all existing fork changes (hostname cloaking, LIST command, etc.).

Mirrors upstream PR Libera-Chat#189.

What this adds

A compile-time registry for free-form help topics not tied to any command handler — channel modes, user modes, or any concept a user might query with HELP <topic>.

Register a topic anywhere with inventory::submit!:

inventory::submit!(HelpTopic {
    topic: "CMODE_SECRET",
    lines: &[
        "CMODE_SECRET (+s)",
        "",
        "Marks the channel as secret. Secret channels are hidden from /LIST",
        "and /WHOIS for users who are not members.",
    ],
});

New API on CommandDispatcher (and forwarded on ClientServer):

  • get_help_topic(topic) — case-insensitive lookup
  • iter_help_topics() — enumerate all topics

How a HELP handler should use both registries

// command docs (from #[command_handler] doc comments, see Libera-Chat/sable#129)
let lines = server.get_command_docs(&topic)
    .or_else(|| server.get_help_topic(&topic));  // this PR

match lines {
    Some(lines) => { /* send 704/705/706 numerics */ }
    None        => { /* send 524 HelpNotFound */ }
}

Introduces a compile-time registry for free-form help topics that are
not tied to a command handler — channel modes, user modes, or any other
concept a user might query with HELP <topic>.

Topics are registered at the call site via inventory::submit!:

    inventory::submit!(HelpTopic {
        topic: "CMODE_SECRET",
        lines: &[
            "CMODE_SECRET (+s)",
            "",
            "Marks the channel as secret.",
        ],
    });

CommandDispatcher gains two new methods:
  - get_help_topic(topic) -> Option<&'static [&'static str]>
  - iter_help_topics()    -> impl Iterator<Item = &'static HelpTopic>

ClientServer forwards both so command handlers can call them directly.

A HELP handler (see Libera-Chat#129) should query the command registry for
command docs and fall back to get_help_topic() for concept entries,
giving full coverage with no runtime I/O.
@gfnord gfnord merged commit 8f667e6 into master Apr 18, 2026
@gfnord gfnord deleted the feat/help-topic-registry-local branch April 18, 2026 18:55
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