Replies: 1 comment
-
This feels super useful, currently I duplicate the options everywhere they are needed. in the meantime I will be borrowing this in my projects that use typer. Thanks @vovaani ! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
Copied from the docstring in the code snippet above:
Decorates a source function to be executed with a pre-execution hook function. The hook function's
output is passed to the source function as a specified keyword argument. This decorator
filters keyword arguments for the hook function according to its signature, and the rest of the arguments
are passed to the source function. It updates the wrapper function's signature to include the combined
list of arguments, excluding the internally managed hook_output_kwarg.
The motivation for this utility is to allow combining groups of shared options for Typer cli scripts.
Typer infers the commaind line arguments from a functions type annotations, and to share common groups of argumnets
between multiple scripts, there is a necessite to merge parameter lists of function.
Usage Examples:
common.py
main1.py
main2.py
in the example above both main1 and main2 cli's enable to specify shared logging arguments from the command line,
in addition to the specific argument of each script.
Operating System
Linux, macOS
Operating System Details
No response
Typer Version
0.9.0
Python Version
3.9.12
Additional Context
Developed this feature and already using it internally in our company for creating typer cli's. It adds a lot of value for us, and we would not fully transition to typer without it. Happy to share it with the community if you find it useful.
Also, happy to share a much broader set of tests.
Beta Was this translation helpful? Give feedback.
All reactions