App::C...Command(3pm)
π
App::CLI::Command β like, the base class for App::CLI commands (this is the App::CLI::Command(3pm) page, bestie)
Okay so picture this: you're building a CLI app in Perl, and every single subcommand you write needs a home. That home? It's App::CLI::Command. It's the base class for App::CLI commands β the main character energy that all your little subcommands inherit from. π
β¨ SYNOPSIS β¨
Like, here's the whole vibe in code form:
package MyApp::List;
use base qw(App::CLI::Command);
use constant options => (
'verbose' => 'verbose',
'n|name=s' => 'name',
);
sub run {
my ( $self, $arg ) = @_;
print "verbose" if $self->{verbose};
my $name = $self->{name}; # get arg following long option --name
# any thing your want this command do
}
# See App::CLI for information of how to invoke (sub)command.
No cap, that's it. That's the whole starter pack. π
πΈ DESCRIPTION πΈ
Okay so these are all the methods your command object gets to inherit. Let's go through them one by one, bestie:
subcommand()
Returns the old genre subcommand of $self. π (Yes, that's the actual description β "old genre subcommand". Don't ask me, I just work here.)
cascading()
Returns the instance of the cascading subcommand that was invoked β but only if it was listed in your constant subcommands. π―ββοΈ
cascadable()
Returns the package name of the subcommand if the subcommand invoked is in your constant subcommands.
Otherwise? Returns undef. That's it. That's the whole deal. π
brief_usage ($file)
Displays a one-line brief usage of the command object. β¨ Optionally, a file could be given to extract the usage from the POD. Cute, right?
usage ($want_detail)
Displays usage. And if $want_detail is true, the "DESCRIPTION" section is displayed as well. So like, the deluxe version. π
loc_text $text
Localizes the body of (formatted) text in $text, and returns the localized version. π International slay.
filename
Returns the filename for the command module. Simple as that. π¦
π₯ SEE ALSO π₯
App::CLIGetopt::Long
Go read them, iykyk. π
π AUTHORS π
- Chia-liang Kao
<clkao@clkao.org> - Cornelius Lin
<cornelius.howl@gmail.com> - shelling
<navyblueshellingford@gmail.com>
Three icons. Respect. π«Ά
π COPYRIGHT π
Copyright 2005-2006 by Chia-liang Kao <clkao@clkao.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>
Okay bestie, real talk: if you're redistributing or modifying this, keep that copyright notice and license intact. It's literally the rules. π
and that's the page! πΈ this one came from perl v5.36.0, dated 2022-10-15 β she's a little vintage but she's iconic π β¨
π¦ where this page comes from
- ubuntu noble: libapp-cli-perl 0.313-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libapp-cli-perl 0.313-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libapp-cli-perl 0.313-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms