MooseX:...Command(3)

✨ MooseX::App::Command β€” the command-class glow-up guide ✨

okay so bestie, this is the manual page for MooseX::App::Command β€” it's part of the User Contributed Perl Documentation, and honestly? it's giving "load command class metaclasses" and being the main character of your CLI app. πŸŽ€


🌸 NAME 🌸

MooseX::App::Command β€” Load command class metaclasses. That's it, that's the vibe. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

Here's the whole setup, literally copy-paste ready:

package MyApp::SomeCommand;

use MooseX::App::Command; # Also loads Moose

option 'testattr' => (
   isa             => 'rw',
   cmd_tags        => [qw(Important! Nice))],
);

command_short_description 'This is a short description';
command_long_description 'This is a much longer description yadda yadda';
command_usage 'script some_command --testattr 123';

no cap, that's the whole flex. ✨


πŸ’– DESCRIPTION πŸ’–

so when you load this class into your command classes, you import all the required symbols and unlock all the documentation features β€” and the list is iconic:

  • Parsing command documentation from Pod πŸ“–
  • Setting the command documentation manually via command_short_description and command_long_description
  • Overriding the automated usage header with custom usage from Pod or via command_usage
  • Adding the cmd_tags, cmd_flag, cmd_aliases and cmd_type attributes to options πŸ‘‘

🧚 FUNCTIONS 🧚

πŸ’œ command_short_description

Set the short description. If you don't set it, this info gets taken from the Pod NAME or ABSTRACT section. Alternatively, it'll be taken from the DistZilla ABSTRACT tag. (yes, it has backup plans, it's organized like that 🫢)

πŸ’œ command_long_description

Set the long description. If not set, this information will be taken from the Pod DESCRIPTION or OVERVIEW sections.

πŸ’œ command_usage

Set custom usage. If not set, this'll be taken from the Pod SYNOPSIS or USAGE section. And if those sections aren't available? the usage information gets autogenerated. slay, it handles itself. ✨

πŸ’œ command_strict

command_strict(0); # default
OR
command_strict(1);

If strict is enabled, the program will terminate with an error message if superfluous/unknown positional parameters are supplied. 😭 If it's disabled, all extra parameters will be copied to the extra_argv attribute. no stress, just vibes.

heads up: the app_strict function in the app classes lets you set this option globally. iykyk. πŸŽ€

⭐ sign-off ⭐

this page is perl v5.42.0, dated 2024-08-09, and it's filed under MooseX:...Command(3) in the User Contributed Perl Documentation. go forth and let your commands be iconic πŸ’…πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from