begin for cpan
This commit is contained in:
parent
e33254437d
commit
030bc4786b
6 changed files with 83 additions and 1 deletions
7
bin/mvcopies
Normal file
7
bin/mvcopies
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#! /usr/bin/env perl
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use FindBin;
|
||||||
|
use lib "$FindBin::Bin/../lib";
|
||||||
|
use MVCopies::CLi;
|
||||||
|
exit MVCopies::CLI->run(\@ARGV);
|
||||||
75
lib/MVCopies/CLI.pm
Normal file
75
lib/MVCopies/CLI.pm
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
package MVCopies::CLI
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Getopt::Long qw(GetOptionsFromArray);
|
||||||
|
use Pod::Usage;
|
||||||
|
use File::Spec;
|
||||||
|
use MVCopies::Core;
|
||||||
|
use MVCopies::Config;
|
||||||
|
|
||||||
|
our $VERSION = '0.01';
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($argv_ref) = @_;
|
||||||
|
my %opts = (
|
||||||
|
recursive => 0,
|
||||||
|
dry_run => 0,
|
||||||
|
help => 0,
|
||||||
|
version => 0,
|
||||||
|
);
|
||||||
|
GetOptionsFromArray(
|
||||||
|
$argv_ref,
|
||||||
|
'r|recursive'=>\$opts{recursive},
|
||||||
|
'dry-run'=>\$opts{dry_run},
|
||||||
|
'help|h'=>\$opts{help},
|
||||||
|
'version|v'=>\$opts{version},
|
||||||
|
) or return _usage();
|
||||||
|
if ($opts{version}) {
|
||||||
|
print "mvcopies version: $VERSION\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ($opts{help}) {
|
||||||
|
return _usage();
|
||||||
|
}
|
||||||
|
my $target_dir = shift @$argv_ref;
|
||||||
|
unless ($target_dir && -d $target_dir) {
|
||||||
|
warn "Error: Must provide valid directory."
|
||||||
|
return _usage();
|
||||||
|
}
|
||||||
|
$target_dir = File::Spec->rel2abs($target_dir);
|
||||||
|
my %core_opts = (
|
||||||
|
target_dir => $target_dir,
|
||||||
|
recursive => $opts{recursive},
|
||||||
|
dry_run => $opts{dry_run},
|
||||||
|
);
|
||||||
|
my $result = MVCopies::Core::run(\%core_opts);
|
||||||
|
return $result ? 0 : 1;
|
||||||
|
}
|
||||||
|
sub _usaage {
|
||||||
|
pod2usage(-verbose => 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
MVCopies::CLI - Command-line interface for mvcopies
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
mvcopies [options] <directory>
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
-r, --recursive Scan directories recursively
|
||||||
|
--dry-run Show what would be moved without moving
|
||||||
|
-h, --help Show help
|
||||||
|
-v, --version Show version
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
This module parses command-line arguments and calls MVCopies::Core
|
||||||
|
to detect and move duplicate files into a "copies" folder.
|
||||||
0
lib/MVCopies/Config.pm
Normal file
0
lib/MVCopies/Config.pm
Normal file
0
lib/MVCopies/Core.pm
Normal file
0
lib/MVCopies/Core.pm
Normal file
0
lib/MVCopies/FileOps.pm
Normal file
0
lib/MVCopies/FileOps.pm
Normal file
2
mvcopies.pl
Normal file → Executable file
2
mvcopies.pl
Normal file → Executable file
|
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/perl
|
#!/data/data/com.termux/files/usr/bin/perl
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue