NAME
config-dump - Display merged configuration from Config::Abstraction
SYNOPSIS
config-dump --file myapp.conf --env_prefix MYAPP_
config-dump --file settings.json --format json
config-dump --format yaml
DESCRIPTION
Loads configuration from supported sources and prints the fully merged configuration to STDOUT. Useful for debugging or inspecting the final values that your application will use.
OPTIONS
- --file FILE
-
Load configuration from the specified file (supports formats your sources handle).
- --env_prefix PREFIX
-
Environment variable prefix to search for (default:
APP_). - --format FORMAT
-
Output format:
dumper,json, oryaml. Default:dumper. - --help
-
Show this help message.
- --version
-
Prints the version of Config::Abstraction
my $config_dirs; my $file; my $env_prefix = 'APP_'; my $help; my $version; my $format = 'dumper'; # dumper | json | yaml
GetOptions( 'file=s' => \$file, 'dirs=s' => \$config_dirs, 'env_prefix=s' => \$env_prefix, 'format=s' => \$format, 'version|V' => \$version, 'help|?' => \$help, ) or pod2usage(2);
pod2usage(1) if $help;
if($version) { print $Config::Abstraction::VERSION, "\n"; exit 0; }
my $args; $args->{'env_prefix'} = $env_prefix if($env_prefix); $args->{'file'} = $file if($file); $args->{'config_dirs'} = split(/,/, $config_dirs) if($config_dirs);
if(my $cfg = Config::Abstraction->new($args)) { my $data = $cfg->all();
if($format eq 'json') {
require JSON;
print JSON::encode_json($data), "\n";
} elsif($format eq 'yaml') {
require YAML;
print YAML::Dump($data);
} else {
require Data::Dumper;
Data::Dumper->import();
no warnings 'once'; # Silence Sortkeys message
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Sortkeys = 1;
print Dumper($data);
}
}
__END__
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 46:
Deleting unknown formatting code V<>