develooper Front page | perl.moose | Postings from October 2010

Q: MooseX::SimpleConfig, MooseX::Getopt, MooseX::Attribute::ENV

Thread Next
From:
Poul H. Sørensen
Date:
October 10, 2010 13:00
Subject:
Q: MooseX::SimpleConfig, MooseX::Getopt, MooseX::Attribute::ENV
Message ID:
4CB21B51.3080508@basefarm.no
Hi

I'm trying to make a perl-module, where (some of) the attributes can be set by merging several configuration files, but
I can't get it to work as expected/required:

When using my module, I want it to be simple to create well-behaved applications (command line arguments overrides environment
etc etc).

Q1: Foo->new_with_options( )
     how do I pass the configuration file as an argument?

Q2: $foo->configfile( )  # or ->set_configfile( )
     how do I parse a configfile later on after constuction?

Q3: --configfile answer1.xml --configfile answer2.xml
     how do I load and merge multiple configuration files?

Q4: --configuration-file or --fille-de-configuration [pun intended]
     how do I call the command-line-flag anything else than "--configfile"?

Q5: BUILD
     how do I load some default configuration files, before all the others?

OK - I guess that not everything may be possible using (the current) MooseX::SimpleConfig and MooseX::Getopt,
but I really hope that I missed out on something...

Otherwise I may have a go at it myself, but I'm rather new to Moose, and wonder if a fair solutions is to
implement an attribute 'configuration-file' isa ArrayRef with a trigger sub (still using MooseX::Getopt)?
If so, how do I get new_with_options() to handle 'configuration_file' => [ qw( answer.xml ) ] (it doesn't
seem to invoke the trigger method (or setting the value) if their is a command-line option --configuratio_file).

Any suggestions on modules or implementation-hints are very welcome!

regards
Poul
Basefarm

-- 
print $Std{'Disclaimer'};
$CC =  +-1; # the Computer Constant - very useful when writing loops.    #
$|=printf "Just another [lazy] %s hacker\r",("PERL","perl")[$i+sleep 1]   #
while $i=$i?0:$CC,1;                                                    ###
__EOF__


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About