Skip Menu |

This queue is for tickets about the Moops CPAN distribution.

Report information
The Basics
Id: 92676
Status: stalled
Priority: 0/
Queue: Moops

People
Owner: perl [...] toby.ink
Requestors: sven.schober [...] uni-ulm.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Implement MooseX::App::Cmd command using Moops
Date: Mon, 03 Feb 2014 13:10:06 +0100
To: bug-Moops [...] rt.cpan.org
From: Sven Schober <sven.schober [...] uni-ulm.de>
Hi! I am trying to implement a [MooseX::App::Cmd](http://search.cpan.org/~mjgardner/MooseX-App-Cmd-0.27/lib/MooseX/App/Cmd.pm) command using Moops. As long as I keep the code in a single file everything works nicely: #!/usr/bin/env perl package myapp::Command; use Moops; class cmd1 extends MooseX::App::Cmd::Command using Moose { method description { return "cmd1"; }; method execute( $opt, $args) { print "Hello World\n"; }; } package main; use Moops; class myapp extends MooseX::App::Cmd using Moose; use Modern::Perl; use myapp; myapp->run; But as soon as I move the definition of `cmd1` to a file `myapp/Command/cmd1.pm` perl complains about the module not returning a true value: $ perl mycmd myapp/Command/cmd1.pm did not return a true value at /usr/share/perl5/site_perl/App/Cmd.pm line 203. The documentation [explicitly states](http://search.cpan.org/~tobyink/Moops-0.030/lib/Moops.pm#Outer_Sugar) the `1;` is not needed. Using `true` won't help either... `App::Cmd` uses `Class::Load::load_class()` to load the command classes, so maybe there's a problem there? My Environment: perl: 5.18.2 Moops: 0.030 MooseX::App::Cmd: 0.27 $ uname -a Linux ylo 3.12.5-1-ARCH #1 SMP PREEMPT Thu Dec 12 12:57:31 CET 2013 x86_64 GNU/Linux Cheers Sven -- Dipl.-Inf. Sven Schober Universität Ulm kiz - Abteilung Infrastruktur 89069 Ulm Tel.: +49 731 50 22484
Download smime.p7s
application/pkcs7-signature 4.4k

Message body not shown because it is not plain text.

What are the exact contents of myapp/Command/cmd1.pm?
Subject: Re: [rt.cpan.org #92676] Implement MooseX::App::Cmd command using Moops
Date: Tue, 04 Feb 2014 08:56:41 +0100
To: bug-Moops [...] rt.cpan.org
From: Sven Schober <sven.schober [...] uni-ulm.de>
On 03.02.2014 22:18, Toby Inkster via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=92676 > > > What are the exact contents of myapp/Command/cmd1.pm? >
I've attached the file to this message. Adding a `1;` at the end will resolve the issue, but that contradicts the documentation.

Message body is not shown because sender requested not to inline it.

Download smime.p7s
application/pkcs7-signature 4.4k

Message body not shown because it is not plain text.

I've just checked in a test case that the `use true` aspect of Moops is working OK, and it seems to pass fine: https://github.com/tobyink/p5-moops/commit/dd1348278706d032bb649bb73903abdc2b996283
Aha! Confirmed. Your package does indeed not return a true value. Adding "1;" to the end allows it to load. Curiously, adding "0;" to the end also allows it to load. Adding any statement (whether it evaluates to true or false) after the class declaration allows it to load. It's possible that Moops' parsing magic interferes with whatever magic true.pm uses.
More complex tests, still passing: https://github.com/tobyink/p5-moops/commit/db6505357d5483381c59bd9c0e8dff14c41fb043 It must be some kind of weird interaction with Class::Load.
Show quoted text
> It must be some kind of weird interaction with Class::Load
Here's some further evidence pointing in that direction... preloading myapp::Command::cmd1 before Class::Load and App::Cmd have sprung into action, allows things to start working. $ cat lib/myapp/Command/cmd1.pm package myapp::Command; use Moops; class cmd1 extends MooseX::App::Cmd::Command using Moose { method description { return "cmd1"; }; method execute( $opt, $args) { print "Hello World\n"; }; } $ cat mycmd package main; use Moops; class myapp extends MooseX::App::Cmd using Moose; use Modern::Perl; use myapp; myapp->run; $ perl -Ilib mycmd myapp/Command/cmd1.pm did not return a true value at /home/tai/.perlbrew/libs/perl-5.20.0@default/lib/perl5/App/Cmd.pm line 203. $ perl -Ilib -mmyapp::Command::cmd1 mycmd Available commands: commands: list the application's commands help: display a command's help screen cmd1: (unknown)
I'm marking this issue as stalled because I don't completely understand what's causing it, and it's difficult to produce a small test case reproducing it without pulling in all of App::Cmd. Unless somebody can figure out exactly what's going on, I don't think there's much I can do other than document the issue. A revamp of the Moops documentation is planned at some point in the future, so it may happen then.