Skip Menu |

This queue is for tickets about the MooX-Cmd CPAN distribution.

Report information
The Basics
Id: 92722
Status: rejected
Priority: 0/
Queue: MooX-Cmd

People
Owner: Nobody in particular
Requestors: sven.schober [...] uni-ulm.de
Cc:
AdminCc:

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



Subject: Moops intergration not working
Date: Tue, 04 Feb 2014 11:44:01 +0100
To: bug-MooX-Cmd [...] rt.cpan.org
From: Sven Schober <sven.schober [...] uni-ulm.de>
Hi! I am using: Moops is up to date. (0.030) MooX::Cmd is up to date. (0.008) I try to implement a command like so: #!/usr/bin/env perl use Modern::Perl '2014'; use Moops; class MyApp { use MooX::Cmd; method execute( ArrayRef $args, ArrayRef $chain ){ warn "MyApp::execute() called"; } } package MyApp::Cmd; use Moops; class cmd1 { use MooX::Cmd; method execute( ArrayRef $args, ArrayRef $chain ){ warn "cmd1 execute called"; } } package main; MyApp->new_with_cmd(); Which yields: $ ./myapp.pl Can't locate object method "new_with_cmd" via package "MyApp" at ./myapp.pl line 26. Cheers Sven
Download smime.p7s
application/pkcs7-signature 4.4k

Message body not shown because it is not plain text.

Hi Sven, I cannot see where this is an issue in MooX::Cmd. It works when those checks are disabled and it seems to me that Moops has a problem. Please address it there and let me know what they think. I flag it as stalled meanwhile. Best regards, Jens
Subject: Re: [rt.cpan.org #92722] Moops intergration not working
Date: Tue, 04 Feb 2014 16:05:25 +0100
To: bug-MooX-Cmd [...] rt.cpan.org
From: Sven Schober <sven.schober [...] uni-ulm.de>
On 04.02.2014 14:15, Jens Rehsack via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=92722 > > > I cannot see where this is an issue in MooX::Cmd. > It works when those checks are disabled and it seems to me that Moops has a problem. >
By "checks" you mean the method signatures, or not using `Moops` at all? Show quoted text
> Please address it there and let me know what they think. I flag it as stalled meanwhile. >
Ok. I'll go and ask them and come back to you later. :) Show quoted text
> Best regards, > Jens >
Download smime.p7s
application/pkcs7-signature 4.4k

Message body not shown because it is not plain text.

Okay, I checked a bit deeper and figured out RT#90805 ... I'm sorry to say, the MooX::Cmd suger isn't available with Moops. You can try to figure out how to consume MooX::Cmd::Role directly in a Moops class.
I'm not entirely sure why, but it looks like namespace::sweep might be removing the subs imported into the class from the MooX::Cmd::Role role. This can be suppressed using: class MyApp :dirty { use MooX::Cmd; ...; } And similarly for any sub-commands. The problem can be reproduced without Moops - just Moo, MooX::Cmd, and namespace::sweep. See attached. I believe the cause is the slightly unorthodox way that MooX::Cmd adds the new_with_cmd sub to the caller package (using Package::Stash in the MooX::Cmd import method). This results in namespace::sweep (and also namespace::autoclean, the Moose meta-object protocol, etc) seeing the new_with_cmd sub as a "foreign" sub. You could work around it by giving the sub a name in the caller package using Sub::Name.
Subject: moox-cmd-vs-namespace-sweep.pl
#!/usr/bin/env perl use v5.14; use warnings; package MyApp { use Moo; use MooX::Cmd; use namespace::sweep; sub execute { warn "MyApp::execute() called"; } } package MyApp::Cmd::cmd1 { use Moo; use MooX::Cmd; use namespace::sweep; sub execute { warn "cmd1 execute called"; } } MyApp->new_with_cmd();