It has been a few days since I started playing with Reply, and I still enjoy it. Command history features from the ReadLine plugin became available once I installed GNU ReadLine and Term::ReadLine::Gnu.
There are still customizations that I would like to make. For example, I write most of my personal code using Perl 5.20’s experimental subroutine signature and postderef features.
Use Shiny Perl 5.20 Features Automatically
A default $HOME/.replyrc
is created the first time you run Reply - unless you already have one, of course. It includes a selection of plugins that will be loaded and a collection of script_line
entries that are evaluated automatically for any new Reply session. I fiddled with mine so that I had a Perl with syntactical sugar in place.
Each line gets its own numbered script_line
entry because of the INI format and the way that input is parsed by Reply.
With this base level of behavior defined, I can run reply
and rewrite my greet
subroutine.
That’s better.
Enabling The Editor
You need Proc::InvokeEditor in order to activate the Editor plugin. I suppose that makes sense. Proc::InvokeEditor is a module that makes it easy to launch your default text editor on behalf of the application, sending the editor buffer back to your application as user input.
Add the Editor plugin entry to your .replyrc
.
And just like that, here is a new #e
command.
It can probably work with EmacsClient, but I have been lazy lately and fallen back to Vim as my $EDITOR
default.
Specifying a Module at Start
I have been exploring Mojolicious, which is a surprisingly full-featured framework considering its small size. The ojo library is a Mojolicious command line tool focused on making your one-liners even more useful. Since Reply is sort of an extended one-liner environment - okay, you can call it a “shell” - ojo and Reply can go together perfectly.
There is no need to add ojo to my .replyrc
, because I will not be needing its functionality every single time I load Reply. Instead I will just tell Reply to load the library when starting those particular sessions.
Let’s keep with the Questhub.io example from the earlier post. I start reply
with the -M
flag to load a specific module on startup.
I know. This is confusing if you are unfamiliar with ojo and the experimental Perl 5.20 postderef feature. We can look at it in smaller pieces.
g
is a shortcut for the get
method of Mojo::UserAgent. There are shortcuts for numerous HTTP verbs in ojo.
j
is a convenience function from Mojo::JSON for encoding and decoding JSON. My experience so far has been that it does what I mean when I use it.
$ref->@*
is an experimental new syntax for accessing the contents of an array reference. It is equivalent to @{ $ref }
or @$ref
. The postderef syntax is a little easier for me to read, but your experience may be different.
All Done
That is enough for now. With the ReadLine plugin and Editor plugin enabled, a nice 2014-ish Perl setup in my .replyrc
, and ojo available when I want it, Reply is downright useful for me.
Backlinks
Got a comment? A question? More of a comment than a question?
Talk to me about this page on:
Added to vault 2024-01-15. Updated on 2024-02-02