Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

moosex::simpleconfig(3pm) [debian man page]

MooseX::SimpleConfig(3pm)				User Contributed Perl Documentation				 MooseX::SimpleConfig(3pm)

NAME
MooseX::SimpleConfig - A Moose role for setting attributes from a simple configfile SYNOPSIS
## A YAML configfile named /etc/my_app.yaml: foo: bar baz: 123 ## In your class package My::App; use Moose; with 'MooseX::SimpleConfig'; has 'foo' => (is => 'ro', isa => 'Str', required => 1); has 'baz' => (is => 'rw', isa => 'Int', required => 1); # ... rest of the class here ## in your script #!/usr/bin/perl use My::App; my $app = My::App->new_with_config(configfile => '/etc/my_app.yaml'); # ... rest of the script here #################### ###### combined with MooseX::Getopt: ## In your class package My::App; use Moose; with 'MooseX::SimpleConfig'; with 'MooseX::Getopt'; has 'foo' => (is => 'ro', isa => 'Str', required => 1); has 'baz' => (is => 'rw', isa => 'Int', required => 1); # ... rest of the class here ## in your script #!/usr/bin/perl use My::App; my $app = My::App->new_with_options(); # ... rest of the script here ## on the command line % perl my_app_script.pl -configfile /etc/my_app.yaml -otherthing 123 DESCRIPTION
This role loads simple configfiles to set object attributes. It is based on the abstract role MooseX::ConfigFromFile, and uses Config::Any to load your configfile. Config::Any will in turn support any of a variety of different config formats, detected by the file extension. See Config::Any for more details about supported formats. Like all MooseX::ConfigFromFile -derived configfile loaders, this module is automatically supported by the MooseX::Getopt role as well, which allows specifying "-configfile" on the commandline. ATTRIBUTES
configfile Provided by the base role MooseX::ConfigFromFile. You can provide a default configfile pathname like so: has '+configfile' => ( default => '/etc/myapp.yaml' ); You can pass an array of filenames if you want, but as usual the array has to be wrapped in a sub ref. has '+configfile' => ( default => sub { [ '/etc/myapp.yaml', '/etc/myapp_local.yml' ] } ); Config files are trivially merged at the top level, with the right-hand files taking precedence. CLASS METHODS
new_with_config Provided by the base role MooseX::ConfigFromFile. Acts just like regular "new()", but also accepts an argument "configfile" to specify the configfile from which to load other attributes. Explicit arguments to "new_with_config" will override anything loaded from the configfile. get_config_from_file Called internally by either "new_with_config" or MooseX::Getopt's "new_with_options". Invokes Config::Any to parse "configfile". AUTHOR
Brandon L. Black, <blblack@gmail.com> LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-19 MooseX::SimpleConfig(3pm)

Check Out this Related Man Page

MooseX::Getopt::Meta::Attribute::NoGetopt(3pm)		User Contributed Perl Documentation	    MooseX::Getopt::Meta::Attribute::NoGetopt(3pm)

NAME
MooseX::Getopt::Meta::Attribute::NoGetopt - Optional meta attribute for ignoring parameters VERSION
version 0.59 SYNOPSIS
package App; use Moose; with 'MooseX::Getopt'; has 'data' => ( metaclass => 'NoGetopt', # do not attempt to capture this param is => 'ro', isa => 'Str', default => 'file.dat', ); DESCRIPTION
This is a custom attribute metaclass which can be used to specify that a specific attribute should not be processed by "MooseX::Getopt". All you need to do is specify the "NoGetopt" metaclass. has 'foo' => (metaclass => 'MooseX::Getopt::Meta::Attribute::NoGetopt', ... ); Use 'traits' instead of 'metaclass' You should rarely need to explicitly set the attribute metaclass. It is much preferred to simply provide a trait (a role applied to the attribute metaclass), which allows other code to further modify the attribute by applying additional roles. Therefore, you should first try to do this: has 'foo' => (traits => ['NoGetopt', ...], ...); Custom Metaclass alias This now takes advantage of the Moose 0.19 feature to support custom attribute metaclass. This means you can also use this as the NoGetopt alias, like so: has 'foo' => (metaclass => 'NoGetopt', cmd_flag => 'f'); AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2013-11-30 MooseX::Getopt::Meta::Attribute::NoGetopt(3pm)
Man Page