Skip to content

Commit

Permalink
check-yaml: Add options --syck, --pp
Browse files Browse the repository at this point in the history
  • Loading branch information
sharyanto committed Oct 26, 2013
1 parent 8a666d1 commit 353772b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bin/check-json
Expand Up @@ -6,6 +6,8 @@ use warnings;

use Getopt::Long;

# VERSION

my $json_mod = '';
GetOptions(
'pp' => sub { $json_mod = 'PP' },
Expand All @@ -25,8 +27,6 @@ if ($json_mod eq 'PP') {
require JSON; $json = JSON ->new->allow_nonref;
}

# VERSION

eval {
undef $/;
$json->decode(~~<>);
Expand Down
33 changes: 32 additions & 1 deletion bin/check-yaml
Expand Up @@ -4,10 +4,26 @@ use 5.010;
use strict;
use warnings;

use YAML::Syck;
use Getopt::Long;

# VERSION

my $yaml_mod = 'XS';
GetOptions(
'syck' => sub { $yaml_mod = 'Syck' },
'xs' => sub { $yaml_mod = 'XS' },
'help' => sub {
print "Usage: $0 [--syck|--xs] <file>\n";
exit 0;
},
);

if ($yaml_mod eq 'Syck') {
require YAML::Syck; YAML::Syck->import;
} elsif ($yaml_mod eq 'XS') {
require YAML::XS; YAML::XS->import;
}

eval {
undef $/;
Load(~~<>);
Expand All @@ -23,4 +39,19 @@ die $@ if $@;
Check YAML syntax. Prints nothing if YAML syntax is okay.
=head1 COMMAND-LINE OPTIONS
=over
=item * --syck
Use L<YAML::Syck>.
=item * --xs
Use L<YAML::XS> (the default).
=back
=cut

0 comments on commit 353772b

Please sign in to comment.