Feature Request
To avoid redundant code, add a template mechanism for argument blocks that appear in multiple commands. Using the with_argparse decorator this is easy by reusing a function that modifies a parser; with_annotated currently has no simple equivalent.
Possible solutions
- Use a TypedDict + Unpack to reuse a named block of annotations:
class ArgumentBlock(TypedDict):
# define reusable keys/values here
...
class App(Cmd):
@with_annotated
def do_a(..., **kwargs: Unpack[ArgumentBlock]) -> None:
...
@with_annotated
def do_b(..., **kwargs: Unpack[ArgumentBlock]) -> None:
...
- Allow attaching a predefined parser to the parser generated by
with_annotated, and expose the resulting namespace inside the decorated method for easy access.
Both approaches reduce duplication; the second may be simpler to implement.
Feature Request
To avoid redundant code, add a template mechanism for argument blocks that appear in multiple commands. Using the
with_argparsedecorator this is easy by reusing a function that modifies a parser;with_annotatedcurrently has no simple equivalent.Possible solutions
with_annotated, and expose the resulting namespace inside the decorated method for easy access.Both approaches reduce duplication; the second may be simpler to implement.