App::C...Command(3pm)

πŸ“¦
version 0.313 Β· 6 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… 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::CLI
  • Getopt::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 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