MooseX::Runnable(3pm)

πŸ“¦
version 0.10 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– MooseX::Runnable β€” the manual page, but make it a group chat πŸ’–

okay bestie, so this is MooseX::Runnable, and it lives in the User Contributed Perl Documentation section (that's the 3pm part, iykyk). it's giving "tag your class as a runnable app" and honestly? iconic. let's go. 🫢


✨ NAME ✨

MooseX::Runnable β€” literally just tags a class as a runnable application. that's the whole job. she's lowkey a queen for it. πŸ‘‘


🌸 VERSION 🌸

version 0.10 β€” that's the vibe we're on, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

so the move is: make a class, tag it runnable, and hand over a run method. like this:

package App::HelloWorld;
use feature 'say';
use Moose;

with 'MooseX::Runnable';

sub run {
   my ($self,$name) = @_;
   say "Hello, $name.";
   return 0; # success
}

then boom, you can run that class as an actual application using the included mx-run script:

$ mx-run App::HelloWorld jrockway
Hello, jrockway.
$

and bestie, listen β€” MooseX::Runnable plays nice with MooseX::Getopt, and with other similar systems too. and if you've written one of those systems yourself? she's extensible, so come through. ✨


πŸ’… DESCRIPTION πŸ’…

MooseX::Runnable is a framework for making classes into runnable applications. and honestly? this role doesn't do anything fancy β€” all it does is tell the rest of the framework "hey, this class is a runnable application, and it has a run method that takes arguments and returns the process' exit code." that's it. that's the whole assignment. πŸŽ€

this is a convention the community has been riding with for a minute now. this role just tells the computer that your class follows this convention, and it lets the computer abstract away some of the tedious stuff that comes with it. the computer is doing your chores. slay. 🧚


πŸ‘‘ REQUIRED METHODS πŸ‘‘

🌟 run

your class must implement run. periodt. it accepts the command-line args (the ones that weren't already eaten by another parser, if that applies to you) and it returns an integer representing the UNIX exit value. so return 0 means success. πŸ’–


πŸ”₯ THINGS YOU GET πŸ”₯

πŸ“ mx-run

this is a script that accepts a MooseX::Runnable class and tries to run it, using MooseX::Runnable::Run.

the syntax is:

mx-run Class::Name

mx-run <args for mx-run> -- Class::Name <args for Class::Name>

for example:

mx-run -Ilib App::HelloWorld --args --go --here

or:

mx-run -Ilib +Persistent --port 8080 -- App::HelloWorld --args --go --here

see how the -- is the little dividing line between "args for mx-run" and "args for your class"? she's a bouncer. πŸ’…

πŸ¦„ MooseX::Runnable::Run

if you don't wanna invoke your app with mx-run, that's totally fine β€” you can write your own custom version using MooseX::Runnable::Run. DIY queen behavior. ✨


🌈 ARCHITECTURE 🌈

MX::Runnable is designed to be extensible, which means:

  • users can run plugins straight from the command-line πŸŽ€
  • application developers can add roles to their class to control behavior πŸ’–

for example, if you consume MooseX::Getopt, the command-line gets parsed with MooseX::Getopt. any recognized args get used to instantiate your class, and any extra args get passed along to run. the leftovers get re-gifted. iconic. 🎁


πŸ’€ CAVEATS πŸ’€

bestie, listen to me very carefully: many of the plugins shipped are unstable. they may go away, change, break, etc. πŸ’€

and if there is no documentation for a plugin, it is probably just a prototype. proceed accordingly, my love. πŸ™ˆ

🫢 SUPPORT 🫢

bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Runnable> β€” or, if email is more your thing, bug-MooseX-Runnable@rt.cpan.org <mailto:bug-MooseX-Runnable@rt.cpan.org>.

there's also a mailing list for users of this distribution, at <http://lists.perl.org/list/moose.html>. join the chat, we're all here. πŸ’Œ

and there's an irc channel too, for users of this distribution: #moose on irc.perl.org <irc://irc.perl.org/#moose>. come say hi. 🌸


⭐ AUTHOR ⭐

Jonathan Rockway <jrockway@cpan.org> β€” the originator, the blueprint, the moment. πŸ‘‘


πŸ’œ CONTRIBUTORS πŸ’œ

  1. Jonathan Rockway <jon@jrock.us>
  2. Karen Etheridge <ether@cpan.org>
  3. Doug Bell <doug.bell@baml.com>
  4. Duke Leto <jonathan@leto.net>

the whole squad ate. no crumbs left. πŸ”₯


This software is copyright (c) 2009 by Jonathan Rockway.

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


and that's the whole page, bestie. πŸ’– this was rendered for you by perl v5.36.0, dated 2022-12-11, and it's the MooseX::Runnable(3pm) page β€” now go tag something runnable and make it everyone's problem. mwah. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from