Devel:...rofile(3pm)

πŸ“¦
version 1.003029 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Devel::REPL::Profile β€” the lil' bundle of code that runs the second re.pl wakes up πŸ’–

Okay bestie, this is the Devel::REPL::Profile page, and honestly? It's giving "make your REPL do stuff for you before you even type a thing." Let's go πŸ¦‹


🌸 VERSION 🌸

version 1.003029 β€” she's specific, she's current, she's that girl πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

Here's the whole vibe in one shot:

package Devel::REPL::Profile::MyProject;

use Moose;
use namespace::autoclean;

with 'Devel::REPL::Profile';

sub apply_profile {
    my ($self, $repl) = @_;
    # do something here
}

1;

That's it. That's the blueprint. Copy it, make it yours, slay ✨


πŸ’œ DESCRIPTION πŸ’œ

So like β€” picture this. You're working on a specific project, and every single time you open the REPL shell you find yourself typing the exact same commands. Loading the same Perl modules. Setting the same configuration. Over and over. Groundhog Day but make it terminal 😭

That's where profiles come in, and profiles are iconic. A profile is a mechanism that lets you package up and distribute all those start-up scripts as straight-up Perl modules. Ship it, share it, reuse it. Periodt. πŸ‘‘


🌈 USAGE 🌈

Lowkey the whole thing is simple: just follow the "SYNOPSIS" up there and you've got yourself a boilerplate profile module. Easy.

Inside that apply_profile method, the $repl variable is your bestie β€” you use it to run any commands exactly the way the user would, right inside the context of their running "Devel::REPL" shell instance. Same shell, same energy 🫢

Say you wanna load a module. That might look a lil' something like this:

sub apply_profile {
    my ($self, $repl) = @_;
    $repl->eval('use Carp');
}

See how we did that? The "eval" method is what you use to run any code. And here's the good part:

  • the user won't see any output from it πŸ™ˆ
  • the code can "safely" die without destroying the REPL shell (she survives, she's resilient πŸ’ͺ)
  • the return value of "eval" will be the return value of whatever code you handed it β€” or, if it died, you get back a "Devel::REPL::Error" object instead

Now, if what you actually want is to load a "Devel::REPL" plugin? Different method, same dream:

$repl->load_plugin('Timing');

Honestly between "load_plugin" and "eval" you've basically got everything you'd ever want to do before the user gets their hands on the shell. And remember β€” plugin features are immediately available, so you can load, say, the "LexEnv" plugin and then declare "my" variables that the user will totally have access to. Main character setup behavior, no cap πŸ‘‘

⭐ Selecting a Profile ⭐

Wanna run the shell with a particular profile? Easy. Just do this:

system$ re.pl --profile MyProject

Or, if that's not your vibe, you can set the environment variable "DEVEL_REPL_PROFILE" to MyProject. Same result, different route πŸ›£οΈ

And here's the naming tea 🍡 β€” when the profile name is unqualified, like in the example right above, the profile is assumed to live in the "Devel::REPL::Profile::" namespace. But if you pass something containing the "::" character sequence, it gets loaded as-is. No assumptions, no namespace injection. Respect the full name, fr fr.


πŸ¦‹ SUPPORT πŸ¦‹

Got bugs? Bestie, we want them. Submit through the RT bug tracker at <https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL> β€” or if email is more your thing, hit up bug-Devel-REPL@rt.cpan.org <mailto:bug-Devel-REPL@rt.cpan.org>.

There's also an IRC channel for users of this distribution, and it lives at "#devel" on "irc.perl.org" <irc://irc.perl.org/#devel-repl>. Come hang out πŸ’¬


πŸ’– AUTHOR πŸ’–

Matt S Trout β€” mst (at) shadowcatsystems.co.uk (<http://www.shadowcatsystems.co.uk/>)


This software is copyright (c) 2007 by Matt S Trout - mst (at) shadowcatsystems.co.uk (<http://www.shadowcatsystems.co.uk/>).

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So like, go wild, but respectfully πŸ’…


And that's the whole page, bestie!! Sending you off with the footer tea: this is perl v5.34.0, dated 2022-06-03, from the Devel:...rofile(3pm) page. Now go write yourself a profile and make your REPL iconic πŸŒŸπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from