Files
falyx/tests/test_parsers/test_tldr.py
Roland Thomas 7dca416346 feat(help): enhance CLI help rendering with Panels and TLDR validation
- Updated `Command.help_signature` to return a `(Panel, description)` tuple,
  enabling richer Rich-based help output with formatted panels.
- Integrated `program` context into commands to display accurate CLI invocation
  (`falyx run …`) depending on mode (RUN, PREVIEW, RUN_ALL).
- Refactored `_show_help` to print `Panel`-styled usage and descriptions instead
  of table rows.
- Added `program` and `options_manager` propagation to built-in commands
  (Exit, History, Help) for consistent CLI display.
- Improved `CommandArgumentParser.add_tldr_examples()` with stricter validation
  (`all()` instead of `any()`), and added new TLDR tests for coverage.
- Simplified parser epilog text to `Tip: Use 'falyx run ?' to show available commands.`
- Added tests for required `Argument` fields and TLDR examples.
- Bumped version to 0.1.73.
2025-07-26 16:14:09 -04:00

48 lines
1.6 KiB
Python

import pytest
from falyx.exceptions import CommandArgumentError
from falyx.parser.command_argument_parser import CommandArgumentParser
@pytest.mark.asyncio
async def test_add_tldr_examples():
parser = CommandArgumentParser()
parser.add_tldr_examples(
[
("example1", "This is the first example."),
("example2", "This is the second example."),
]
)
assert len(parser._tldr_examples) == 2
assert parser._tldr_examples[0].usage == "example1"
assert parser._tldr_examples[0].description == "This is the first example."
assert parser._tldr_examples[1].usage == "example2"
assert parser._tldr_examples[1].description == "This is the second example."
@pytest.mark.asyncio
async def test_bad_tldr_examples():
parser = CommandArgumentParser()
with pytest.raises(CommandArgumentError):
parser.add_tldr_examples(
[
("example1", "This is the first example.", "extra_arg"),
("example2", "This is the second example."),
]
)
@pytest.mark.asyncio
async def test_add_tldr_examples_in_init():
parser = CommandArgumentParser(
tldr_examples=[
("example1", "This is the first example."),
("example2", "This is the second example."),
]
)
assert len(parser._tldr_examples) == 2
assert parser._tldr_examples[0].usage == "example1"
assert parser._tldr_examples[0].description == "This is the first example."
assert parser._tldr_examples[1].usage == "example2"
assert parser._tldr_examples[1].description == "This is the second example."