Runnin...mentary(3pm)
π¦ Running::Commentary π¦
straight out of the User Contributed Perl Documentation, 3pm section, no cap β¨
πΈ NAME πΈ
Running::Commentary β it calls system cleanly, and it keeps you posted with tracking messages the whole time. bestie behaviour fr fr π
β¨ VERSION β¨
this doc is describing Running::Commentary version 0.000005. iconic number, love that for us π
π SYNOPSIS π
okay so here's the vibe:
use Running::Commentary;
# Set a lexically scoped flag for all subsequent calls...
# (No announcements, if this flag set)
run_with -nomessage if !$verbose;
# Act like system(), only louder and cleaner...
run 'Resetting' => "rm -rf '$ROOT_DIR'"
or die "Couldn't reset";
# Act like system(), but croak() if the command fails...
run -critical, 'Building Makefile' => 'perl Makefile.PL';
# Calls to run() may be nested, to allow subtasks to be tracked...
run 'Running tests'
=> sub {
for my $file (@profiled_files) {
push @profiles, "$NAMING_ROOT/$file.out";
local $ENV{NYTPROF} = "file=$profiles[-1]";
run -nooutput, "Testing $file"
=> "perl -d:NYTProf $profiled_path/$file >& /dev/null";
}
};
likeβ¦ look at it. nested. tracked. gorgeous. ππ
π DESCRIPTION π
this module gives you exactly one subroutine: run(). and the whole point of it is that it's a more informative, less error-prone glow-up of the built-in system(). π
it ALSO gives you a compile-time keyword: run_with, which is how you set lexically scoped default options for run(). so like, set it once, it applies for the rest of the scope. main character energy tbh π
π INTERFACE π
π run $MESSAGE => $SYSTEM_CMD;
this does the system $SYSTEM_CMD thing, EXCEPT:
- it returns true on success and false on failure (not that cursed raw exit-status situation)
- it announces what it's doing like a little narrator π«Ά
example time:
run 'Resetting directories' => "rm -rf @STD_DIRS"
β¦would first print out:
Resetting directories...
β¦then it actually runs the system command, and then it finishes the message:
Resetting directories...done
and if the command failed for some reason, the completion part tells you what went wrong:
Resetting directories...
rm: tets: No such file or directory
Resetting directories...exited with value 1
or, in the other flavour of bad:
Resetting directories...failed to execute: No such file or directory
note bestie: that tets up there is exactly what the original says. we do not fix, we do not touch, we preserve β (keeping every detail is the whole assignment)
π run $MESSAGE => sub {...};
this flavour wants a subroutine reference as its second argument, not a string. same deal though: prints the tracking message, runs the sub, prints the outcome. π«
the sub gets run inside an eval block, so any exceptions it throws get caught and reported as the outcome at the end of the tracking message. if you want those exceptions to actually escape back out of the run() call instead, that's what the -critical option is for (scroll down, it's in OPTIONS, we got you).
for example:
run 'Printing your data' => sub {
for my $datum (@data) {
say " $datum->{key}: $datum->{value}";
}
}
would output:
Printing your data...
Name: Fred
Age: 28
Score: 87
Printing your data...done
and you can nest calls to run() using this form. like:
run 'Running your request' => sub {
for my $cmd (split /\n/, $request) {
run "Running '$cmd'" => $cmd;
}
}
which would produce:
Running your request...
Running 'rm source'...done
Running 'rebuild_files'...done
Running 'make test'.......done
Running your request...done
look at those little dots lining up π the alignment ate, honestly
π run $SYSTEM_CMD;
π run sub {...};
when you call it with no message, run() just executes the system command or the subroutine and prints absolutely no progress message whatsoever. in other words it's just a quietly better system(). still better though. always better. π
π run_with @OPTIONS;
the run_with keyword takes any of the options that run() accepts (check "OPTIONS" below). whatever options you hand it become the default arguments for run() for the rest of the current lexical scope. set it and forget it β¨
say you want every subsequent failed command to throw an exceptionβ¦
{
run_with -critical;
run "loading" => $LOAD_CMD;
run "checking" => $CHECK_CMD;
run "installing" => $INSTALL_CMD;
run "cleaning up" => $CLEANUP_CMD;
}
β¦or you want to silence message printing on request:
{
run_with -nomessage if $opt{-quiet};
run "loading" => $LOAD_CMD;
run "checking" => $CHECK_CMD;
run "installing" => $INSTALL_CMD;
run "cleaning up" => $CLEANUP_CMD;
}
β οΈ important bestie: run_with is a compile-time keyword, NOT a subroutine. so you only ever call it as a statement, aka in void context. don't be out here trying to use its return value, there isn't one π«
π OPTIONS π
all of these can go anywhere in the argument list of a call to run() or run_with. sprinkle as needed π
-nomessageβ run the command with no tracking message. usually you'd use it as a conditional lexical option, like:
run_with -nomessage if $opt{quiet};
the output of the actual system command still gets printed though β unless -nooutput or -silent is also in play.
-showmessageβ run the command with the tracking message printed. this is your girl when you need to turn message printing back ON inside a scope where-nomessageis already in effect. π«-nooutputβ run the command without echoing any of its output. the tracking message still prints β unless-nomessageor-silentis also specified. π€«-showoutputβ run the command and echo the output. perfect for flipping command echoing back on inside a scope where-nooutputis already in effect. π₯-silentβ literally identical to:-nomessage, -nooutput. the stealth mode combo β¨-showallβ literally identical to:-showmessage, -showoutput. super handy for overriding-silentin a nested scope. the un-stealth π-criticalβ normally, if a call torun()fails it just returnsundef. but with-critical, any call torunthat fails immediately throws an exception. no quiet failure, we're not doing that π-nocriticalβ putsrun()back to returningundefon failure. useful for overriding-criticalin a nested scope. π«Ά-dryβ instead of actually executing the specified system command, it just prints it out. ideal for dry runs while you're developing and testing. no accidentalrm -rfsituations, we love to see it π-colour => \%COLOUR_SPECβ specify the colours used for messages and output. the values of the hash are the colours, and the keys say what each colour is for. like so:
run_with -colour => {
MESSAGE => 'white', # Colour for tracking messages
DONE => 'bold cyan', # Colour for success messages
FAILED => 'yellow on_red', # Colour for failure messages
OUTPUT => 'clear' # Colour for command output
};
each colour spec has to be a single string, which gets split on whitespace and then passed along to the Term::ANSIColor module. if that module isn't available, this option is silently ignored. (rude of it, but okay.)
this option may also be spelled -color.
-nocolourβ print all messages and output with no special colours at all. neutral palette era π€
this option may also be spelled -nocolor.
π ERROR HANDLING π
on failure, run() normally does one of two things: returns undef, OR throws an exception (if -critical is specified).
BUT. plot twist. Running::Commentary incorporates the Lexical::Failure module, so you can also request other failure responses for any particular scope, just by passing a named argument when you load the module:
# Report errors by confess()-ing...
use Running::Commentary fail => 'confess';
# Report errors by returning a failure object...
use Running::Commentary fail => 'failobj';
# Report errors by setting a flag variable...
use Running::Commentary fail => \$error;
# Report errors by calling a subroutine...
use Running::Commentary fail => \&error_handler;
for the details of all the available options, go read the documentation of Lexical::Failure. it's the whole plug-and-play failure system, obsessed π
π DIAGNOSTICS π
Bad argument to 'use Running::Commentary'β the module accepts exactly one named argument:
use Running::Commentary 'fail' => $fail_mode;
(see "ERROR HANDLING" up there π)
so yeah, you apparently passed it something else. or maybe you misspelled 'fail'? we've all been there bestie, no judgement π«Ά
Useless call to run() with no commandβrun()expects at least one argument (aside from any configuration options), namely: something to execute. that something can be either a string containing a system command, or a subroutine reference.
you gave it neither of those, so the call to run() was superfluous. nothing to run, nothing happened, awkward π
or, possibly, you wanted run_with instead. (classic mix-up, honestly)
π§ CONFIGURATION AND ENVIRONMENT π§
Running::Commentary requires no configuration files and no environment variables. zero setup, we just work β¨ (a low-maintenance king)
π DEPENDENCIES π
- this module requires Perl v5.14 or later.
- it also requires the modules:
Lexical::Failure, andKeyword::Simple.
π INCOMPATIBILITIES π
none reported. π (nothing to see here, move along)
π BUGS AND LIMITATIONS π
no bugs have been reported. π
please report any bugs or feature requests to bug-running-commentary@rt.cpan.org, or through the web interface at <http://rt.cpan.org>. (link as-is, bestie, we keep it verbatim)
π AUTHOR π
Damian Conway "<DCONWAY@CPAN.org>"
π LICENCE AND COPYRIGHT π
Copyright (c) 2012, Damian Conway "<DCONWAY@CPAN.org>". All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
π DISCLAIMER OF WARRANTY π
okay bestie, deep breath, this is the part where the lawyers start SCREAMING in all caps and honestly? valid. π«Ά
so here's the deal: this software is licensed FREE OF CHARGE, and because of that, THERE IS NO WARRANTY FOR THE SOFTWARE, to the extent permitted by applicable law. none. zero. nada. π
and like β unless somebody literally said otherwise in writing, the copyright holders and/or other parties are handing you the software "AS IS", with NO WARRANTY OF ANY KIND, whether expressed or implied. and yes that includes (but is not limited to, bestie, they're covering their bases) the implied warranties of MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE. it's giving "you get what you get". π
the entire risk as to the quality and performance of the software? that's on YOU. all yours. and if the software turns out to be defective, you assume the cost of all necessary servicing, repair, or correction. not them. you. π
okay and now the second paragraph, which is the big one, the main character of liability clauses:
IN NO EVENT β unless required by applicable law or agreed to in writing β will any copyright holder, or any other party who may modify and/or redistribute the software as permitted by the above licence, be liable to you for damages. any of them. including any general, special, incidental, or consequential damages arising out of the use or inability to use the software.
and just so we're being thorough (they are, they're being SO thorough), that includes but is not limited to:
- loss of data π
- data being rendered inaccurate
- losses sustained by you or third parties
- a failure of the software to operate with any other software
and this holds EVEN IF such holder or other party has been advised of the possibility of such damages. like, even if they knew it could go wrong, still not their problem. no cap. π
so yeah. that's the vibe. it's free, it's "as is", and the risk is yours to hold. iconic legal behaviour, honestly. π β¨
and that's a wrap on the whole page, bestie!! π this one came from the perl v5.34.0 docs, dated 2022-06-17 β go forth and run stuff, just like, at your own risk. mwah. ππ¦πΈ
π¦ where this page comes from
- debian bookworm: librunning-commentary-perl 0.000005-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: librunning-commentary-perl 0.000005-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librunning-commentary-perl 0.000005-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librunning-commentary-perl 0.000005-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librunning-commentary-perl 0.000005-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms