App::Cmd::Setup(3)

✨ NAME ✨

bestie, this is App::Cmd::Setup β€” the little helper that sets up your App::Cmd classes πŸ’– it lives in the App::Cmd::Setup section of the perl manual, and honestly? it's giving backstage pass energy πŸŽ€


🌸 VERSION 🌸

version 0.338 β€” that's the one, periodt πŸ’…


πŸ¦‹ OVERVIEW πŸ¦‹

okay so App::Cmd::Setup is a helper library, and what it does is help you set up base classes that get used as part of an App::Cmd program 🫢 for the most part though? you should just go read the tutorial for how you're supposed to use this library, fr fr.

this class is lowkey useful in three scenarios, and we're gonna go through all of them, no skipping πŸ‘‘

when writing your App::Cmd subclass

so instead of writing this:

package MyApp;
use parent 'App::Cmd';

...you can literally just write:

package MyApp;
use App::Cmd::Setup -app;

the benefits of doing it this way are mostly minor, ngl β€” they relate to sanity-checking your class. but the significant benefit is that this form lets you specify plugins, like:

package MyApp;
use App::Cmd::Setup -app => { plugins => [ 'Prompt' ] };

plugins are described over in App::Cmd::Tutorial, go look πŸ‘€

doing this also lets you override the default configuration passed to Getopt::Long. by default, this configuration includes pass_through, which is what allows subdispatch to work correctly. if you're not using subdispatch, and you want your command to exit on unknown options, you can say:

package MyApp;
use App::Cmd::Setup -app => { getopt_conf => [] };

when writing abstract base classes for commands

like, when you write a subclass of App::Cmd::Command that's intended for other commands to use as their base class, you should use App::Cmd::Setup πŸ’œ for example, if you want all the commands in MyApp to inherit from MyApp::Command, you might want to write that package like this:

package MyApp::Command;
use App::Cmd::Setup -command;

do not confuse this with the way you'll write specific commands:

package MyApp::Command::mycmd;
use MyApp -command;

again, this form mostly does some validation and setup behind the scenes for you 🧚 you can use base if you prefer, no judgement.

when writing App::Cmd plugins

App::Cmd::Plugin is a mechanism that lets an App::Cmd class inject code into all of its command classes, giving them utility routines ✨

to write a plugin, you must use App::Cmd::Setup. and as we saw up above, you must also use App::Cmd::Setup to set up your App::Cmd subclass if you wanna consume plugins.

for more info on writing plugins, see App::Cmd::Manual and App::Cmd::Plugin πŸ“š


🌈 PERL VERSION 🌈

this library should run on perls released even a long time ago. it should work on any version of perl released in the last five years.

although it may work on older versions of perl, no guarantee is made that the minimum required version won't be increased. the version may be increased for any reason, and there's no promise that patches will be accepted to lower the minimum required perl.

so like... don't come for it if it needs a newer perl someday, bestie 😭 that's just the deal.

πŸ‘‘ AUTHOR πŸ‘‘

Ricardo Signes <cpan@semiotic.systems> β€” iconic, we stan πŸ’–


this software is copyright (c) 2025 by Ricardo Signes.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself 🌸


okay that's the whole page, you're so welcome πŸ’… this was App::Cmd::Setup, perl v5.42.0, dated 2026-01-16 β€” and that's the vibe check, passed with flying colors πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from