Boldra has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have a lot (30 94 and growing) of MooseX::Getopt based scripts inheriting from a single role (My::App). My::App includes quite a few getopt-enabled switches which don't make sense in some of the scripts which inherit from it. The result is that when the user runs script --help, they get a page and a half of options which are irrelevant.
I can suppress some options from a script by adding following to the attribute declarations in the inheriting script:
has( "+$_", traits => ['NoGetopt'] ) for qw<fast_db html_output japane +se_wts debug_soap lease_tolerance>;
This is effective, but not pretty, and since I have so many classes which use it, it would be nice to put it into a sub in a shared package. My::App seems like the logical choice, but:
has '+attr' is not supported in roles ...Which is fine with me, but I'm calling this in a class, it's just that Moose thinks I'm calling it in a role. has isn't a method, so I can't use my package to tell Moose that it's being called from a role. It looks like has is using caller to see where it's being called from.
So what do people suggest? Should I:
What do you think?
Update Much more than 30
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: MooseX::GetOpt disable in role
by tobyink (Canon) on Jun 21, 2013 at 10:58 UTC | |
by Boldra (Curate) on Jun 21, 2013 at 11:54 UTC | |
by markjugg (Curate) on Aug 06, 2013 at 19:25 UTC |