App::Y...ommand(3pm)
π App::Yath::Command(3pm) β the vibe π
okay bestie, welcome to App::Yath::Command, aka the base class for every single yath command. like, all of them. every one. this is the blueprint, the blueprint-est blueprint. π«Ά
β¨ NAME β¨
App::Yath::Command β it's literally the base class for yath commands. that's the whole job description. π
πΈ DESCRIPTION πΈ
so this is the parent class for any and all yath commands, no exceptions, no cap. if you wanna add a shiny new yath command of your own? you subclass this package. that's it, that's the door, come on in. π
π¦ SYNOPSIS π¦
here's the whole ritual, copy it exactly:
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;
}
iconic. genuinely ate. β¨
π CLASS METHODS π
watch closely, these are the class-level ones:
$string = $cmd_class->cli_help(settings => $settings, options => $options)β this generates the command line help for whatever command you throw at it. and ngl? you are generally NOT gonna wanna override this one. it's doing great actually.$settingsshould be an instance ofTest2::Harness::Settings. and$optionsshould be an instance ofApp::Yath::Optionsif you provide it β but lowkey this method is usually smart enough to fill in the details itself when you leave it out. π§$multi_line_string = $cmd_class->description()β the long-form description of the command. this is the one used insidecli_help(). π@list = $cmd_class->doc_args()β gives you a list of argument names for the command, which gets used to generate documentation. π$string = $cmd_class->generate_pod()β this can generate POD documentation straight from the command itself, using all the other fields listed in this section, plus all the applicable command line options specified in the command. self-documenting queen behavior. π$string = $cmd_class->group()β used for sorting/grouping commands in the"yath help"output. the existing groups are:
' 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.
okay so unless your command OBVIOUSLY and CLEARLY belongs in one of the groups up there, you should probably just make your own group, fr fr. and please do not prefix it with a space to make it float β ' test' is a special case, you are not that special. π (affectionate)
$string = $cmd_class->name()β the name of the command. by default it's the last part of the package name. you will probably never, ever want to override this. please don't. π$short_string = $cmd_class->summary()β a short summary of what this command is. the lil one-liner intro. πΈ
π OBJECT METHODS π
and now the instance-level ones:
$bool = $cmd->always_keep_dir()β by default the working directory gets deleted when yath exits π. some commands, likeApp::Yath::Command::start, need to keep that directory around. so override this method and return true if your command uses the workdir and needs it to survive. π$arrayref = $cmd->args()β get an arrayref of the command line arguments AFTER options have been process/removed. so like, the leftovers. the after-party of args. β¨$bool = $cmd->internal_only()β set this to true if you do not want your command showing up in the help output. secret menu energy, iykyk. π€«$exit_code = $cmd->run()β this is the main entrypoint for the command. you MUST override this one, no skipping bestie. and this method should return an exit code. π$settings = $cmd->settings()β get the settings as populated by the command line options. π«Ά$cmd->write_settings_to($directory, $filename)β a lil helper method that writes the settings to a specified directory and filename. the file gets written as JSON. π
here's a heads up tho: if you're subclassing another command like App::Yath::Command::test, you may want to override this to a no-op so the settings file doesn't get written at all β the App::Yath::Command:run command does exactly that. π
π₯ SOURCE π₯
the source code repository for Test2-Harness lives at http://github.com/Test-More/Test2-Harness/. go peek, it's giving open source royalty. π
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
β AUTHORS β
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
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/
and that's the whole page bestie!! π
β¨ this lil beauty comes from perl v5.40.1, dated 2026-05-10, and yes the manpage header is out here looking like App::Y...ommand(3pm) β truncated for the drama of it all. periodt. ππ¦π
π¦ where this page comes from
- ubuntu stonking: libtest2-harness-perl 1.000172-1 Β· Artistic-1.0-Perl OR 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