-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Argument groups #48
Comments
My initial thought on how to implement something like this would be to include a Pull requests are welcome! |
We are interested in this use case too - specifically being able to add a group (derived from dataclass) onto a traditional ArgumentParser. The use case is that we have a main library that supports plugins, and the plugins can add a group (for their special case) to the argument parser. Right now we are doing a set of args verbatim, but this is problematic in that we have to carry around the args throughout the various functions to get to the plugin logic. The issue is that it wouldn't work well for strictly Python use cases. A solution with a dataclass would be much more ideal! |
In case this is helpful to someone else, the use case we have is wanting to be able to have this custom plugin add arguments on the fly. Our original strategy was using a custom group, but then we had this group that needed to be passed via the argparse.Namespace, which is not ideal if someone wants to use your classes external to an argparser. What we would up doing is:
We have an early writeup here: https://github.com/snakemake/snakemake-executor-flux#how-does-it-work. @mivade I am wondering why that function is considered private, and if a public variant (for this use case of quickly modifying an argument parser) might be exposed? |
Closed by #57. |
Hi, it is possible to use argument groups in argparse?
This is useful when you want to group arguments together.
For example, you can group arguments by their functionality.
Docs: https://docs.python.org/3/library/argparse.html#argument-groups
The text was updated successfully, but these errors were encountered: