% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>
Devscripts::Config - devscripts Perl scripts configuration object
# Configuration module
package Devscripts::My::Config;
use Moo;
extends 'Devscripts::Config';
use constant keys => [
[ 'text1=s', 'MY_TEXT', qr/^\S/, 'Default_text' ],
# ...
];
has text1 => ( is => 'rw' );
# Main package or script
package Devscripts::My;
use Moo;
my $config = Devscripts::My::Config->new->parse;
1;
Devscripts Perl scripts configuration object. It can scan configuration files (/etc/devscripts.conf and ~/.devscripts) and command line arguments.
A devscripts configuration package has just to declare:
Each element of keys constant is an array containing four elements which can be undefined:
It is possible to declare some additional rules to check the logic between options:
use constant rules => [
sub {
my($self)=@_;
# OK
return 1 if( $self->a < $self->b );
# OK with warning
return ( 1, 'a should be lower than b ) if( $self->a > $self->b );
# NOK with an error
return ( 0, 'a must not be equal to b !' );
},
sub {
my($self)=@_;
# ...
return 1;
},
];
Constructor
Launches parse_conf_files(), parse_command_line() and check_rules
Reads values in /etc/devscripts.conf and ~/.devscripts
Parse command line arguments
Xavier Guimard <yadd@debian.org>
Copyright 2018 by Xavier Guimard <yadd@debian.org>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.