How can I call nested click commands from other Python applications? #2814
Unanswered
and-viceversa
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hopefully I didn't miss something obvious.
I've got a standard Click application with one
Group
and several nested commands.my_group
->
sub_command_one
->
sub_command_two
->
sub_command_three
Now that this application is looking good, I've got the idea to call these subcommands from other (non-Click) Python tools. I can call these sub commands directly through a typical module import, but that omits the
Groups
's contextctx
from transferring down to the child. So any options and arguments etc that apply to the Group are not passed to the children. The childctx
is a NoneType.What am I missing here? Is there an idiomatic way to call nested commands arbitrarily from other Python code?
Edit: Calling the original Click application via
subprocess
or similar is not desirable, because I'd like to use the Click command's return values in the calling application.Beta Was this translation helpful? Give feedback.
All reactions