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.
This commit is contained in:
47
tests/test_parsers/test_tldr.py
Normal file
47
tests/test_parsers/test_tldr.py
Normal file
@ -0,0 +1,47 @@
|
||||
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."
|
Reference in New Issue
Block a user