One important use case from Tap/tapify that is missing is the ability to create a subparser that can parse arguments for different functions depending on which subparser is called. This is made difficult because tapify both instantiates a Tap class and runs the function without exposing the Tap class, which is needed for subparsing. We propose to refactor tapify by first creating a function called convert_to_tap that takes a function and dynamically creates a Tap subclass definition with the arguments of that function. In tapify, this Tap class can be instantiated and used to parse arguments and run the function. This Tap class can also be used explicitly or can be used as a subparser. Please see a potential implementation here: https://github.com/swansonk14/chemfunc/blob/main/chemfunc/utils.py#L13
One important use case from
Tap
/tapify
that is missing is the ability to create a subparser that can parse arguments for different functions depending on which subparser is called. This is made difficult becausetapify
both instantiates aTap
class and runs the function without exposing theTap
class, which is needed for subparsing. We propose to refactortapify
by first creating a function calledconvert_to_tap
that takes a function and dynamically creates aTap
subclass definition with the arguments of that function. Intapify
, thisTap
class can be instantiated and used to parse arguments and run the function. ThisTap
class can also be used explicitly or can be used as a subparser. Please see a potential implementation here: https://github.com/swansonk14/chemfunc/blob/main/chemfunc/utils.py#L13