Skip to content

Commit

Permalink
Merge pull request #27 from explosion/feature/docs-bool-negation
Browse files Browse the repository at this point in the history
  • Loading branch information
ines committed Apr 20, 2023
2 parents 70644fc + 30964ee commit deb5aec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion radicli/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path
import re

from .util import format_type, DEFAULT_PLACEHOLDER
from .util import format_type, BooleanOptionalAction, DEFAULT_PLACEHOLDER

if TYPE_CHECKING:
from .cli import Radicli, Command
Expand Down Expand Up @@ -61,6 +61,9 @@ def _command(
table = []
for ap_arg in cmd.args:
name = f"`{ap_arg.arg.option or ap_arg.id}`"
if ap_arg.action == BooleanOptionalAction and ap_arg.default is True:
assert ap_arg.arg.option
name += f"/`--no-{ap_arg.arg.option[2:]}`"
if ap_arg.arg.short:
name += ", " + f"`{ap_arg.arg.short}`"
default = ""
Expand Down
3 changes: 3 additions & 0 deletions radicli/tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ def convert_my_custom_type(v: str) -> MyCustomType:
"child",
arg1=Arg(help="Argument one", converter=convert_my_custom_type),
arg2=Arg(help="Argument two"),
arg3=Arg("--arg3", help="Argument three"),
)
def child2(
arg1: MyCustomType,
arg2: ExistingFilePath = cast(
ExistingFilePath, Path(__file__).parent / "__init__.py"
),
arg3: bool = True,
):
"""This is command 3 and its child."""

Expand Down Expand Up @@ -107,4 +109,5 @@ def child2(
| --- | --- | --- | --- |
| `arg1` | `MyCustomType` | Argument one | |
| `arg2` | `ExistingFilePath (Path)` | Argument two | `__init__.py` |
| `--arg3`/`--no-arg3` | `bool` | Argument three | `True` |
"""
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
version = 0.0.22
version = 0.0.23
description = Radically lightweight command-line interfaces
url = https://github.com/explosion/radicli
author = Explosion
Expand Down

0 comments on commit deb5aec

Please sign in to comment.