The "stretch" commit. Fix deprecation warnings with Mojolicious 7.21
Require Mojolicious 7.15 for Mojo::File support
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
package CrashTest::Command::update;
use Mojo::Base 'Mojolicious::Command';
use Mojo::JSON::MaybeXS;
use Mojo::JSON qw/decode_json/;
use Mojo::File qw/path/;
# Short description
has description => 'Update crash';
# Short usage message
has usage => <<EOF;
Usage: APPLICATION update file ...
EOF
sub run {
my ($self, @args) = @_;
if(scalar @args < 1) {
say $self->usage;
exit 0;
}
foreach my $jsonfile(@args) {
my $path = path($jsonfile);
my $uuid = $path->basename('.json');
my $dmp_file = $path->dirname->child("$uuid.dmp");
my $dmp = undef;
if(-e $dmp_file) {
$dmp = $dmp_file->slurp;
}
eval {
my $pjson = decode_json($path->slurp);
$self->app->crash_reports->update($uuid, $pjson, $pjson->{client_info}, $dmp);
};
warn $@ if $@;
}
}
1;