Skip to content

Commit 2856f02

Browse files
v68 Added help help
1 parent 2574633 commit 2856f02

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pydantic_argparse_next/parser/parser.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,17 @@ def show_help(self):
232232
)
233233
console.print(usage)
234234

235+
# Help help
236+
text = ["--help (-H)", "Show this message and exit."]
237+
table = Table(show_header=False, box=None)
238+
table.add_row(*text)
239+
panel = Panel(
240+
table,
241+
title=None,
242+
border_style="bold yellow"
243+
)
244+
console.print(panel)
245+
235246
# Arguments
236247
def get_help_panel(x: list[Argument | KeywordArgument | Subcommand], title: str | None) -> Panel:
237248
table = Table(show_header=False, box=None)

tests/help/test_help.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ class Test(BaseModel):
4343
assert exc_info.value.code == 0
4444

4545

46+
def test_help_general_2(capsys):
47+
class Test(BaseModel):
48+
a: str = pa.KwArg(..., description="test")
49+
b: str = pa.KwArg(None, description="test")
50+
51+
output = read_output(Test, ["--help"], capsys).out
52+
53+
assert "--help (-H)" in output
54+
assert "Show this message and exit." in output
55+
56+
4657
def test_parserconfig(capsys):
4758
class Test(BaseModel):
4859
__parserconfig__ = pa.parserconfig(

0 commit comments

Comments
 (0)