1package Minilla::CLI::Clean;
2use strict;
3use warnings;
4use utf8;
5use ExtUtils::MakeMaker qw(prompt);
6use File::Path qw(rmtree);
7
8use Minilla::Project;
9use Minilla::Util qw(parse_options);
10
11sub run {
12    my ($self, @args) = @_;
13
14    my $yes_opt = 0;
15    parse_options(
16        \@args,
17        'y!' => \$yes_opt,
18    );
19
20    my $project = Minilla::Project->new();
21    my @targets = grep { -e $_ } (
22        glob(sprintf("%s-*", $project->dist_name)),
23        'blib',
24        'Build',
25        'MYMETA.json',
26        'MYMETA.yml',
27        '_build_params',
28        '_build',       # M::B
29        'Makefile',
30        'pm_to_blib',
31    );
32    print("Would remove $_\n") for (@targets);
33    if ($yes_opt || prompt('Remove it?', 'y') =~ /y/i) {
34        rmtree($_) for @targets;
35    }
36}
37
381;
39__END__
40
41=head1 NAME
42
43Minilla::CLI::Clean - Clean up directory
44
45=head1 SYNOPSIS
46
47    % minil clean
48
49        -y    delete files without asking
50
51=head1 DESCRIPTION
52
53Remove some temporary files.
54
55