package App::DeDuppy; # ABSTRACT: generate json files from casperjs test arguments use strict; use warnings; use 5.010; use Carp; use Moo; use MooX::Options; use JSON; option 'arglist' => (is => 'ro', format => 's', required => 1, doc => 'the original casperjs arguments'); option 'output' => (is => 'ro', format => 's', predicate => 'is_output_set'); has 'options' => (is => 'ro', default => sub { {} }); has 'subcommand' => (is => 'ro', writer => 'set_subcommand', predicate => 'subcommand_is_set'); has 'paths' => (is => 'ro', default => sub { [] }); sub truthify_maybe { $_[0] eq 'false' ? JSON::false : $_[0] eq 'true' ? JSON::true : $_[0]; } sub arrayrefify_maybe { my @values = split(/,/, $_[0]); if (@values > 1) { return [ map { truthify_maybe($_) } @values ]; } return truthify_maybe($values[0]); } sub repsac_nur { # if you play it backwards it sounds like an Elvis record my $self = shift; foreach my $argument (split(/\s+/, $self->arglist)) { # four types of args: --option, --option=value (there's always # a = in there fortunately), subcommand (the first arg that's # not an option), and test files if ($argument =~ m/^--(?