App-genconf
view release on metacpan or search on metacpan
package App::genconf;
#ABSTRACT: The world's simplest config file generator
use strict;
use warnings;
use File::Find;
use Getopt::Long qw/ GetOptions :config bundling /;
use Path::Class qw/ file /;
use Template;
use Try::Tiny;
=head1 NAME
App::genconf - The world's simplest config file generator
=head1 SYNOPSIS
# Create a config template
vi templates/config/myapp_local.yml
app_name: [% APP_NAME %]
is_production: [% IS_PRODUCTION %]
# Add the required rontment variables
export APP_NAME=LOLCatter
export IS_PRODUCTION=0
# Run genconfig
genconfig templates/config
=head1 DESCRIPTION
Genconf is a very simple config file generation tool. Source control config
templates; use a simple command to genrate|update whatever environment's config
files.
=head1 TEMPLATE TIPS
# Make config values required by using the assert plugin, which causes the
# template processor to throw an error if undef values are returned:
[% USE assert %]
app_name: [% env.assert.APP_NAME %]
# Cut out optional config sections with a simple IF:
[% IF DB_CONN_STRING and DB_USERNAME and DB_PASSWORD %]
db_connection_info:
- [% DB_CONN_STRING %]
- [% DB_USERNAME %]
- [% DB_PASSWORD %]
[% END %]
# Use the TAGS directive if you need [% in your config:
[% TAGS [- -] %]
[%User]
name = [- USER_NAME -]
password = [- USER_PASSWORD -]
How it helps:
=over
=item
Store all configs in version control
=item
Never commit passwords to version control
=item
( run in 0.922 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )