App-DistUtils
view release on metacpan or search on metacpan
script/uninstall-dist view on Meta::CPAN
#!perl
use 5.010;
use strict;
use warnings;
use App::DistUtils;
#use List::Util qw(first);
use Perinci::CmdLine::Any;
use Perinci::Object;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2023-05-20'; # DATE
our $DIST = 'App-DistUtils'; # DIST
our $VERSION = '0.154'; # VERSION
our %SPEC;
$SPEC{uninstall_dist} = {
v => 1.1,
summary => 'Uninstall a Perl distribution',
args => {
%App::DistUtils::dist_arg_multiple,
force => {
schema => 'bool',
cmdline_aliases => {f=>{}},
},
},
deps => {
prog => 'cpanm',
},
};
sub uninstall_dist {
require Dist::Util;
my %args = @_;
my $res = envresmulti();
my $dists = $args{dist};
for my $dist0 (@$dists) {
(my $dist = $dist0) =~ s/-/::/g;
my $packlist = Dist::Util::packlist_for($dist);
unless ($packlist) {
$res->add_result(404, "Can't find .packlist for $dist0",
{item_id=>$dist0});
next;
}
# the easy way
my $mod = $dist;
# the proper way
#@lines = do { open my($fh), "<", $packlist; map {chomp} <$fh> };
## find the first module for module name to feed to cpanm
#my $mod = first { /\.pm\z/ } @lines;
## XXX read package declaration from module file
system "cpanm", "--uninstall", (('--force') x !!$args{force}), $mod;
if ($?) {
$res->add_result(500, "Uninstall $dist0 failed: $!",
{item_id=>$dist0});
} else {
$res->add_result(200, "OK",
{item_id=>$dist0});
}
}
$res->as_struct;
}
Perinci::CmdLine::Any->new(
url => "/main/uninstall_dist",
)->run;
# ABSTRACT: Uninstall a Perl distribution
# PODNAME: uninstall-dist
__END__
=pod
=encoding UTF-8
=head1 NAME
uninstall-dist - Uninstall a Perl distribution
=head1 VERSION
This document describes version 0.154 of uninstall-dist (from Perl distribution App-DistUtils), released on 2023-05-20.
=head1 SYNOPSIS
% list-dist-contents Text-ANSITable
=head1 DESCRIPTION
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
( run in 1.886 second using v1.01-cache-2.11-cpan-39bf76dae61 )