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] 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.