mojo generate role

54 views
Skip to first unread message

Roger Crew

unread,
Oct 1, 2019, 9:23:53 AM10/1/19
to Mojolicious
so, on the theory that if I'm doing something at least twice there should be a script for it,
I wrote a "mojo generate role", role.pm,

that is mostly a ripoff of "mojo generate plugin" but with some better defaults
i.e.,
   
mojo generate role BaseClass RoleName

creates a rudimentary development directory for the BaseClass::Role::RoleName role
with a single testcase template (...that will actually work straight out of the box if you chose
a baseclass that doesn't require arguments to build...).

I can do a pull request if there's interest in this and you want actual code to look at.

Roger Crew

unread,
Oct 23, 2019, 6:16:30 PM10/23/19
to Mojolicious
what's the right way to get something like this
(i.e., new mojo generate commands, or variations/additional-options on existing ones)
added to my 'mojo' command search space. 

I can't do it as a plugin, since plugin stuff doesn't becomes available until you actually add the plugin to the application you're currently working on (assuming it even is an application that you're working on, as opposed to a plugin, or a role, or something else), and the mojo generate commands are all for creating source-trees from scratch.

About the only thing I can come up with is playing games with @INC in order to swap in my own version of Mojo::HelloWorld to add stuff to its ->commands,

... which all looks to be at least medium evil.

but I also hate to ask for Yet Another Environment Variable (but maybe that's the RIght Thing here?)
  

Dan Book

unread,
Oct 23, 2019, 6:26:07 PM10/23/19
to mojol...@googlegroups.com
You would install it under Mojolicious::Command::generate, as described at https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Adding-commands-to-Mojolicious. Easiest if you have a local::lib and simply put it under ~/perl5/lib/perl5/Mojolicious/Command/...

-Dan

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/e3795845-2934-4dce-b95f-a1d76fc9d6f4%40googlegroups.com.

Dan Book

unread,
Oct 23, 2019, 6:27:17 PM10/23/19
to mojol...@googlegroups.com
There are many such global commands released to CPAN for example: https://metacpan.org/search?q=Mojolicious%3A%3ACommand%3A%3A

-Dan

Dan Book

unread,
Oct 23, 2019, 6:30:00 PM10/23/19
to mojol...@googlegroups.com
Actually the generate command moved so it would be under Mojolicious::Command::Author::generate::foo in recent versions.

-Dan

On Wed, Oct 23, 2019 at 6:25 PM Dan Book <gri...@gmail.com> wrote:

Roger Crew

unread,
Oct 23, 2019, 6:50:42 PM10/23/19
to Mojolicious
yes, mine actually is under ..::Author::generate::

(didn't realize it was actually okay to pee in that space, although maybe this is more of a case of cant-do-anything-about-it; welcome to CPAN)
To unsubscribe from this group and stop receiving emails from it, send an email to mojol...@googlegroups.com.

Dan Book

unread,
Oct 23, 2019, 6:58:24 PM10/23/19
to mojol...@googlegroups.com
The general policy is the same as applied to plugins or things in the Mojo:: namespace: it's fine to upload CPAN modules under them as long as you defer to the core team if they want to claim the namespace.

-Dan

To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/4265d0f9-01bd-4f60-bd7a-b69fa3951d62%40googlegroups.com.

Roger Crew

unread,
Oct 27, 2019, 2:55:01 AM10/27/19
to Mojolicious
Reply all
Reply to author
Forward
0 new messages