From bd6f68e2a3d753bbf335211f592065a106a5c5d3 Mon Sep 17 00:00:00 2001 From: Andy Mikhaylenko Date: Sat, 30 Dec 2023 19:29:25 +0100 Subject: [PATCH] docs: fix example --- docs/source/the_story.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/source/the_story.rst b/docs/source/the_story.rst index ecce529..44ce7ec 100644 --- a/docs/source/the_story.rst +++ b/docs/source/the_story.rst @@ -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: