Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions limacharlie/help_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
Related commands: search, event, detection, ai generate-query
"""

HELP_TOPICS["sensors"] = """\
HELP_TOPICS["sensor"] = """\
Sensors
=======

Expand Down Expand Up @@ -159,7 +159,7 @@
Related commands: sensor, tag, endpoint-policy, task, installation-key
"""

HELP_TOPICS["outputs"] = """\
HELP_TOPICS["output"] = """\
Outputs
=======

Expand Down Expand Up @@ -196,7 +196,7 @@
Related commands: output, stream
"""

HELP_TOPICS["extensions"] = """\
HELP_TOPICS["extension"] = """\
Extensions
==========

Expand Down Expand Up @@ -338,7 +338,7 @@
Related commands: auth, api-key, user
"""

HELP_TOPICS["events"] = """\
HELP_TOPICS["event"] = """\
Events
======

Expand Down Expand Up @@ -368,7 +368,7 @@
Related commands: event, search, detection, stream
"""

HELP_TOPICS["detections"] = """\
HELP_TOPICS["detection"] = """\
Detections
==========

Expand All @@ -394,7 +394,7 @@
Related commands: detection, rule, fp, stream
"""

HELP_TOPICS["adapters"] = """\
HELP_TOPICS["adapter"] = """\
Adapters (USP - Universal Sensor Protocol)
==========================================

Expand Down Expand Up @@ -423,7 +423,7 @@
Related commands: adapter, usp, cloud-sensor
"""

HELP_TOPICS["downloads"] = """\
HELP_TOPICS["download"] = """\
Downloads - Sensor Installers & Adapter Binaries
=================================================

Expand Down Expand Up @@ -852,13 +852,25 @@
def get_help_topic(name: str) -> str | None:
"""Get help topic content by name.

Tries an exact match first, then falls back to simple singular/plural
variants so that both ``limacharlie help output`` and
``limacharlie help outputs`` resolve to the same topic.

Args:
name: Topic name (e.g., 'd&r-rules', 'hive', 'lcql').

Returns:
str or None.
"""
return HELP_TOPICS.get(name)
topic = HELP_TOPICS.get(name)
if topic is not None:
return topic
# Try adding/removing a trailing "s" for singular/plural tolerance.
if name.endswith("s"):
topic = HELP_TOPICS.get(name[:-1])
else:
topic = HELP_TOPICS.get(name + "s")
return topic


def list_help_topics() -> list[str]:
Expand All @@ -873,13 +885,23 @@ def list_help_topics() -> list[str]:
def get_cheatsheet(name: str) -> str | None:
"""Get cheatsheet content by name.

Tries an exact match first, then falls back to simple singular/plural
variants for tolerance.

Args:
name: Cheatsheet name.

Returns:
str or None.
"""
return CHEATSHEETS.get(name)
sheet = CHEATSHEETS.get(name)
if sheet is not None:
return sheet
if name.endswith("s"):
sheet = CHEATSHEETS.get(name[:-1])
else:
sheet = CHEATSHEETS.get(name + "s")
return sheet


def list_cheatsheets() -> list[str]:
Expand Down