<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -7,12 +7,51 @@ use strict;
 use warnings;
 use Config::Any;
 use Data::Dump qw( pp );
+use Getopt::Long;
 
-my $cfg = Config::Any-&gt;load_files({ files =&gt; \@ARGV, use_ext =&gt; 1 });
+my $opt_json;
+GetOptions('json' =&gt; \$opt_json) || usage();
+
+if ($opt_json) {
+  eval { require JSON };
+  fatal(&quot;option --json requires the JSON module from CPAN&quot;) if $@;
+}
+
+usage('Missing required configuration file to parse') unless @ARGV;
+
+my $cfg = Config::Any-&gt;load_files({files =&gt; \@ARGV, use_ext =&gt; 1});
 
 for my $c (@$cfg) {
   while (my ($filename, $config) = each %$c) {
-    print &quot;Got configuration from file '$filename':\n&quot;, pp($config), &quot;\n&quot;;
+    print &quot;&gt;&gt;&gt; Got configuration from file '$filename':\n&quot;;
+
+    if ($opt_json) { print JSON::to_json($config) }
+    else           { print pp($config)            }
+
+    print &quot;\n&quot;;
   }
 }
 
+
+#############
+
+sub fatal {
+  my $mesg = join('', @_);
+  
+  print &quot;FATAL: $mesg\n&quot; if $mesg;
+  exit(1);
+}
+
+sub usage {
+  print &lt;&lt;&quot;  EOU&quot;;
+
+Usage: x-perl-check-config [--json] config_file*
+
+Parses 1 or more configuration files (JSON, .ini, YAML supported)
+and dumps the internal perl structure or as JSON if the '--json'
+option is used.
+
+  EOU
+  
+  fatal(@_);
+}</diff>
      <filename>bin/x-perl-check-config</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fdafc036cb1a7e5c16bcd3e4d83f41eff7c7a420</id>
    </parent>
  </parents>
  <author>
    <name>Pedro Melo</name>
    <email>melo@simplicidade.org</email>
  </author>
  <url>http://github.com/melo/scripts/commit/8b49ecdd5f25cd84836ea2aa9fb9ed53dce857b7</url>
  <id>8b49ecdd5f25cd84836ea2aa9fb9ed53dce857b7</id>
  <committed-date>2009-10-12T09:39:50-07:00</committed-date>
  <authored-date>2009-10-12T09:39:50-07:00</authored-date>
  <message>Add proper usage and the option --json to x-perl-check-config

If --json is given, outputs all found config files as JSON.

Signed-off-by: Pedro Melo &lt;melo@simplicidade.org&gt;</message>
  <tree>d535f5a12a8d4247cb47720fc75355a73306f472</tree>
  <committer>
    <name>Pedro Melo</name>
    <email>melo@simplicidade.org</email>
  </committer>
</commit>
