App::Yath::Command(3pm) | User Contributed Perl Documentation | App::Yath::Command(3pm) |
App::Yath::Command - Base class for yath commands
This is the base class for any/all yath commands. If you wish to add a new yath command you should subclass this package.
package App::Yath::Command::mycommand; use strict; use warnings; use App::Yath::Options(); use parent 'App::Yath::Command'; # Include existing option sets include_options( 'App::Yath::Options::Debug', 'App::Yath::Options::PreCommand', ..., ); # Add some custom options option_group {prefix => 'mycommand', category => 'mycommand options'} => sub { option foo => ( description => "the foo option", default => 0, ); }; # This is used to sort/group commands in the "yath help" output sub group { 'thirdparty' } # Brief 1-line summary sub summary { "This is a third party command, it does stuff..." } # Longer description of the command (used in yath help mycommand) sub description { return <<" EOT"; This command does: This That Those EOT } # Entrypoint sub run { my $self = shift; my $settings = $self->settings; my $args = $self->args; print "Hello Third Party!\n" # Return an exit value. return 0; }
$settings should be an instance of Test2::Harness::Settings.
$options should be an instance of App::Yath::Options if provided. This method is usually capable of filling in the details when this is omitted.
Existing groups:
' test' # Space in front to make sure test related command float up 'log' # Log processing commands 'persist' # Commands related to the persistent runner 'zinit' # The init command and related command sink to the bottom.
Unless your command OBVIOUSLY and CLEARLY belongs in one of the above groups you should probably create your own. Please do not prefix it with a space to make it float, ' test' is a special case, you are not that special.
If you are subclassing another command such as App::Yath::Command::test you may want to override this to a no-op to prevent the settings file from being written, the App::Yath::Command:run command does this.
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.
Copyright 2020 Chad Granum <exodist7@gmail.com>.
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/
2023-03-12 | perl v5.36.0 |