-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
AfterFunc execution details #1917
Comments
@shrimalmadhur The AfterFunc will be run only once after the subcommand actions have been completed. So in your case of |
@dearchap thanks for the answer. my detailed case is I want to send telemetry data to an endpoint after any command gets executed - I need the whole command path while sending telemetry. |
Yes that's correct. If you pass in the same function in all the places the context for the command will be passed to you |
I see but interestingly I found an issue in v2.27.2
This always returns only the leaf command path but it's supposed to return whole command path. I don't see In the latest master branch, the code is
This will insure parent command path is also included |
ok |
@shrimalmadhur you can start using v3, It is almost production ready. |
@dearchap oh awesome. excited for using v3. Thanks for the update, I will close this issue now. |
I am using AfterFunc feature and adding it to the root command
According to documentation it will execute after every sub command too. The issue I'm facing is that the
*Context
doesn't have knowledge of full command.For example if my command is
cmd opreration1 operatione
thectx.Command.FullName()
gives backcmd
. I am wondering if that's the expected behavior and I have to addAfter
in all the leaf commands to get that. If that's the expected behavior, my question is, why not have the current subcommand execution context inAfter
function so that I can get command full name by only attachingAfterFunc
to root command?The text was updated successfully, but these errors were encountered: