Acme-Sort-Sleep
view release on metacpan or search on metacpan
local/bin/config_data view on Meta::CPAN
for ($defs{$name}{type}) {
/^=s$/ and $out .= " <string>";
/^=s%$/ and $out .= " <string>=<value>";
}
pad_line($out, 35);
$out .= "$defs{$name}{desc}\n";
}
$out .= <<EOF;
Examples:
$0 --module Foo::Bar --feature bazzable
$0 --module Foo::Bar --config magic_number
$0 --module Foo::Bar --set_feature bazzable=1
$0 --module Foo::Bar --set_config magic_number=42
EOF
return $out;
}
sub pad_line { $_[0] .= ' ' x ($_[1] - length($_[0]) + rindex($_[0], "\n")) }
__END__
=head1 NAME
config_data - Query or change configuration of Perl modules
=head1 SYNOPSIS
# Get config/feature values
config_data --module Foo::Bar --feature bazzable
config_data --module Foo::Bar --config magic_number
# Set config/feature values
config_data --module Foo::Bar --set_feature bazzable=1
config_data --module Foo::Bar --set_config magic_number=42
# Print a usage message
config_data --help
=head1 DESCRIPTION
The C<config_data> tool provides a command-line interface to the
configuration of Perl modules. By "configuration", we mean something
akin to "user preferences" or "local settings". This is a
formalization and abstraction of the systems that people like Andreas
Koenig (C<CPAN::Config>), Jon Swartz (C<HTML::Mason::Config>), Andy
Wardley (C<Template::Config>), and Larry Wall (perl's own Config.pm)
have developed independently.
The configuration system employed here was developed in the context of
C<Module::Build>. Under this system, configuration information for a
module C<Foo>, for example, is stored in a module called
C<Foo::ConfigData>) (I would have called it C<Foo::Config>, but that
was taken by all those other systems mentioned in the previous
paragraph...). These C<...::ConfigData> modules contain the
configuration data, as well as publicly accessible methods for
querying and setting (yes, actually re-writing) the configuration
data. The C<config_data> script (whose docs you are currently
reading) is merely a front-end for those methods. If you wish, you
may create alternate front-ends.
The two types of data that may be stored are called C<config> values
and C<feature> values. A C<config> value may be any perl scalar,
including references to complex data structures. It must, however, be
serializable using C<Data::Dumper>. A C<feature> is a boolean (1 or
0) value.
=head1 USAGE
This script functions as a basic getter/setter wrapper around the
configuration of a single module. On the command line, specify which
module's configuration you're interested in, and pass options to get
or set C<config> or C<feature> values. The following options are
supported:
=over 4
=item module
Specifies the name of the module to configure (required).
=item feature
When passed the name of a C<feature>, shows its value. The value will
be 1 if the feature is enabled, 0 if the feature is not enabled, or
empty if the feature is unknown. When no feature name is supplied,
the names and values of all known features will be shown.
=item config
When passed the name of a C<config> entry, shows its value. The value
will be displayed using C<Data::Dumper> (or similar) as perl code.
When no config name is supplied, the names and values of all known
config entries will be shown.
=item set_feature
Sets the given C<feature> to the given boolean value. Specify the value
as either 1 or 0.
=item set_config
Sets the given C<config> entry to the given value.
=item eval
If the C<--eval> option is used, the values in C<set_config> will be
evaluated as perl code before being stored. This allows moderately
complicated data structures to be stored. For really complicated
structures, you probably shouldn't use this command-line interface,
just use the Perl API instead.
=item help
Prints a help message, including a few examples, and exits.
( run in 0.750 second using v1.01-cache-2.11-cpan-39bf76dae61 )