Skip to content

Commit

Permalink
docs: fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
neithere committed Dec 30, 2023
1 parent 2f67656 commit bd6f68e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/source/the_story.rst
Expand Up @@ -98,16 +98,22 @@ A minimal example (note how there's literally nothing CLI-specific here)::
A more complete example::

from typing import Annotated
from argh import Choices, Help
from argh import Help


FORMAT_CHOICES = "json", "yaml"
DEFAULT_FORMAT = FORMAT_CHOICES[0]


def load(
path: Annotated[str, Help("path to the file to load")],
*,
file_format: Annotated[str, Choices(FORMAT_CHOICES))] = DEFAULT_FORMAT,
file_format: Annotated[str, Literal[FORMAT_CHOICES])] = DEFAULT_FORMAT,
dry_run: bool = False
) -> str:
return do_something(path, file_format, dry_run)


argh.dispatch_command(load)

The syntax is subject to change but the essence is clear:
Expand Down

0 comments on commit bd6f68e

Please sign in to comment.