TEST2::MANUAL::TOOLING::PLUGIN::TOOLCOMPLETES(3perl)

✨ NAME ✨

Test2::Manual::Tooling::Plugin::ToolCompletes β€” it's the Perl Programmers Reference Guide page that teaches you how to add behaviors that happen when a tool completes work πŸ’– (and yeah, we're in 3perl territory, so you already know this is Perl module docs, bestie)


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, this tutorial is here to help you understand how to add behaviors that occur when a tool is <emphasis>done</emphasis> with its work. periodt.

the ✨lore✨ is this: all tools need to acquire and then release a context. so for this tutorial, we're making use of the release hooks that get called every single time a tool releases the context object. every time. no cap. πŸ”₯


πŸ’… COMPLETE CODE UP FRONT πŸ’…

because we're not gonna make you scroll for the good stuff, here's the whole thing:

package Test2::Plugin::MyPlugin;

use Test2::API qw{test2_add_callback_context_release};

sub import {
    my $class = shift;

    test2_add_callback_context_release(sub {
        my $ctx_ref = shift;

        print "Context was released\n";
    });
}

1;

πŸŽ€ LINE BY LINE πŸŽ€

breaking it all the way down, no crumbs left:

  • use Test2::API qw{test2_add_callback_context_release}; β€” this imports the test2_add_callback_context_release() callback. that's it, that's the whole job 🫢
  • test2_add_callback_context_release(sub { ... })
  • my $ctx_ref = shift β€” the coderefs for test2_add_callback_context_release() will receive exactly 1 argument, and that argument is the context being released. one. just one. 😌
  • print "Context was released\n" β€” prints a notification whenever the context is released. iconic behavior honestly πŸ’€βœ¨

🌸 SEE ALSO 🌸

  • Test2::Manual β€” the Primary index of the manual. go there, it's giving main character energy πŸ‘‘

🧚 SOURCE 🧚

the source code repository for Test2-Manual can be found at https://github.com/Test-More/test-more/ β€” go peek, iykyk πŸ’œ


πŸ‘‘ MAINTAINERS πŸ‘‘

Chad Granum <exodist@cpan.org>


🌈 AUTHORS 🌈

Chad Granum <exodist@cpan.org>


Copyright Chad Granum <exodist@cpan.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/


and that's the whole page bestie, you ate πŸ’…βœ¨

signing off from perl v5.44.0, dated 2026-10-17, on the Test2::Manual::Tooling::Plugin::ToolCompletes page (the 3perl one) πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms